Document to Markdown
Convert HTML, Word (DOCX) and text-based PDF files to clean Markdown for a language model, in your browser, with tokens counted before and after.
What it does
Open an HTML, Word (.docx), PDF, text or Markdown file — or paste HTML — and get clean Markdown back: headings, paragraphs, lists, tables, links and code, without the page chrome, scripts, styles and layout a model does not need. The tokens are counted before and after clean-up, and Send to Chunking opens the result in the Chunking visualizer.
Try it: a web page with navigation and scripts, a documentation page, a three-page PDF report, a scanned PDF, or a Word memo. All five are made up for the examples.
HTML
The HTML is parsed by your browser's own DOMParser. A parsed document is inert: nothing in it runs, loads or navigates — no script, no image, no stylesheet, no frame — and the Markdown is shown as text, never rendered.
- Kept: headings, paragraphs, lists (nested, numbered from their start), quotes, code blocks with their language, inline code, bold, italic, strikethrough, links, tables (as GitHub-style tables) and rules.
- Dropped: scripts, styles, frames, embedded objects, forms, SVG, comments, and anything hidden.
- Main content only reads just the
<main>element when there is one, and drops navigation, the site's header and footer, and asides. - Links are kept as
[text](url); ajavascript:ordata:link keeps its text only. Images become their alt text, orif you ask for it. - Characters Markdown would read as markup —
*,`,[,],<, and a_that could start emphasis — are escaped with a backslash, and so is a line that would otherwise read as a heading, a quote or a list item.
Word documents
A .docx file is read by mammoth, which maps Word's structure — heading styles, lists, tables, bold and italic, links, footnotes — to plain HTML and ignores fonts, colours and layout. The HTML is then cleaned the same way as above. Images keep only their alt text: their bytes are never converted or embedded.
A DOCX file is a ZIP archive, so before the converter sees it, the archive is measured: every part is inflated with a hard limit of 64 MB for the whole file, and an archive that would expand past it — a ZIP bomb — is refused. So is an archive that could be read two ways (a part hidden past the directory's declared count, two parts with the same name, a header that disagrees with the directory), an encrypted or damaged archive, and any part that declares XML entities, which Word never writes.
A PDF is read by Mozilla's PDF.js. Only its text layer is read, and PDF.js is given no address to fetch anything from.
A PDF holds positioned text, not paragraphs, so its structure is inferred:
- Lines join into a paragraph until the gap to the next line is more than one and a half lines, or the type size changes.
- A one-line paragraph set noticeably larger than the body text becomes a heading.
- A line starting with a bullet becomes a list item.
- Drop running headers, footers and page numbers leaves out a line that opens or closes at least half the pages (and three or more) with the same text once digits are ignored, and a lone page number.
- Rejoin hyphenated words joins
infor-/mationwhen the next line starts in lower case.
There is no OCR. A scanned page is an image with no text layer: the page says which pages have none, and a PDF with no text at all is reported as such, not guessed at. A PDF whose fonts need external character maps (some CJK documents) can come out garbled or empty — nothing is downloaded to read them, and the page warns when a map was needed — and text laid out in columns can come out interleaved. A password-protected PDF cannot be read.
Tokens before and after
Both counts use OpenAI's o200k_base or cl100k_base encoding, exactly, through the same token counter as the other tools; other models' tokenizers differ, so treat the counts as a comparison. "Before" is the HTML source, the Word document as HTML before clean-up, or the PDF's text layer as it comes out; "after" is the Markdown.
Limits
Files up to 25 MB, pasted HTML up to 5,000,000 characters, and PDF text up to 5,000,000 characters. Word documents and PDFs are read in a Web Worker that is stopped after 45 seconds, so a malformed file cannot hang the page. The page shows the first 200,000 characters of the Markdown; Copy and Download have all of it.
What it does not do
It converts files on your computer. It does not fetch a page from a URL, recognise text in images, or keep anything. Nothing you open or paste is sent to Salyro or anywhere else, and a shared link holds the settings only — never the document. Send to Chunking hands the Markdown to the next page through this tab's own session storage, which is cleared when the tab closes, and never through the address.
FAQ
Why is the Markdown shorter than the page?
Navigation, scripts, styles, markup and layout are what clean-up removes; they are often most of an HTML file's tokens, and none of them helps a model read the content.
Why did a table or a heading not come through from my PDF?
A PDF does not say what is a table or a heading; they are inferred from positions and type sizes, and a table's cells come out as lines of text. For structured content, convert the original Word or HTML file instead, if you have it.
Sources
HTML parsing: the HTML Standard's DOMParser, as the browser implements it. Word documents: mammoth. PDF text: PDF.js. Tables: the GitHub Flavored Markdown specification. Exact token counts: the token layer these tools share, held to OpenAI's tiktoken.
Where the numbers come from
This tool works only on what you enter. It uses no external data and runs entirely in your browser.
