# Convert to JSON

Group: Markdown and HTML. JavaScript Object Notation. The API converts 32 formats to JSON. These are the options, by input format.

## Example

cURL:

```bash
curl https://api.switchfile.io/v1/convert \
  -H "Authorization: Bearer $SWITCHFILE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://example.com/input.doc","to":"json"}'
```

Node.js:

```js
const res = await fetch("https://api.switchfile.io/v1/convert", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.SWITCHFILE_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({"url":"https://example.com/input.doc","to":"json"}),
});
console.log(await res.json());
```

## From 30 formats

Inputs: doc, docm, docx, dot, dotm, dotx, fodp, fods, fodt, odp, ods, odt, otp, ots, ott, pot, potm, potx, pps, ppsx, ppt, pptm, pptx, rtf, xls, xlsm, xlsx, xlt, xltm, xltx

| Option | Type | Default | Description |
| --- | --- | --- | --- |
| `password` | string | not set | Password to open the file. |

## From PDF

| Option | Type | Default | Description |
| --- | --- | --- | --- |
| `pages` | string | not set | Pages to convert, for example 1-3,5 or all. Up to 50 pages without credits, up to 300 with credits. |
| `password` | string | not set | Password to open the PDF. |
| `images_ocr` | boolean | true | Read text from scanned pages. |
| `ocr_language` | string | auto | Language of scanned pages: "auto" (detected on the first scanned page) or "deu", "eng", "spa", "fra", joined with + as in "deu+eng". |

## From TXT

| Option | Type | Default | Description |
| --- | --- | --- | --- |
| `encoding` | string | utf-8 | Text encoding of the input file, for example utf-8, windows-1252, iso-8859-1 or utf-16. |
| `password` | string | not set | Password to open the file. |
