Output formats
The format field of POST /v1/convert decides what you get in the data field of the answer. There are three formats.
format |
Type of data |
Use it when |
|---|---|---|
json (default) |
A JSON object | You want structured content, or the fields of a schema |
markdown |
A string | You want readable text with its structure (headings, tables), for review, search or an LLM |
html |
A string | You want to show the document on a web page |
The value is not case sensitive (JSON works), and any other value, such as txt or docx, is refused with 400 and a message listing the allowed formats.
Markdown
curl -s https://api.docslice.app/v1/convert \
-H "Authorization: Bearer $DOCSLICE_API_KEY" \
-F "file=@invoice.pdf" \
-F "format=markdown"
import json
import os
import requests
api_key = os.environ["DOCSLICE_API_KEY"]
with open("invoice.pdf", "rb") as handle:
response = requests.post(
"https://api.docslice.app/v1/convert",
headers={"Authorization": f"Bearer {api_key}"},
files={"file": ("invoice.pdf", handle, "application/pdf")},
data={"format": "markdown"},
timeout=120,
)
print(json.dumps(response.json(), indent=2))
const fs = require("node:fs");
const form = new FormData();
form.append("file", new Blob([fs.readFileSync("invoice.pdf")], { type: "application/pdf" }), "invoice.pdf");
form.append("format", "markdown");
fetch("https://api.docslice.app/v1/convert", {
method: "POST",
headers: { Authorization: `Bearer ${process.env.DOCSLICE_API_KEY}` },
body: form,
})
.then((response) => response.json())
.then((data) => console.log(JSON.stringify(data, null, 2)));
<?php
$curl = curl_init('https://api.docslice.app/v1/convert');
curl_setopt_array($curl, [
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . getenv('DOCSLICE_API_KEY')],
CURLOPT_POSTFIELDS => [
'file' => new CURLFile('invoice.pdf', 'application/pdf', 'invoice.pdf'),
'format' => 'markdown',
],
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 120,
]);
echo curl_exec($curl);
curl_close($curl);
The answer has the same envelope as any conversion: success, mode, document (file name, type, pages, characters, processing_time_ms, ocr_applied), output_format, data, schema_applied, ocr_applied and input_truncated. With format=markdown, data is a string:
{
"success": true,
"mode": "sync",
"output_format": "markdown",
"data": "INVOICE INV-2847\n\nDate: 2026-05-21\n..."
}
JSON
With format=json and no schema, data is an object with the content of the document. With a schema, data follows it: that is the way to get just the fields you need. The schema is only used with json; if you send one together with markdown or html it is ignored.