HTML to JSON Converter
CV-100Paste HTML and get a JSON tree where each element has a tag, attributes and children. Or turn a table into an array of row objects.
Runs in your browser. Nothing is uploaded.
HTML
JSON
How to use it
- Paste your HTML.
- Press HTML to JSON tree for the full structure.
- Or press Table to JSON rows to read a table by its header row.
- Copy or download the JSON.
The tree format
Each element becomes an object with "tag", "attrs" and "children". The "attrs" object holds attribute names and values, with an empty string for an attribute that has no value, such as disabled. The "children" array holds text strings and more element objects, in document order. Keys that have nothing to show are left out, so a br is just {"tag":"br"}. Tag and attribute names are lowercased and character references are decoded.
Whitespace, comments and messy markup
Text is trimmed and runs of whitespace collapse to one space, except inside pre, script, style and textarea. Whitespace-only text is dropped. Comments and the doctype are left out unless you tick the option. Unclosed li, p, td and similar tags are closed the way browsers close them, and stray closing tags are ignored. Nothing is run or fetched, so scripts in the HTML do nothing here.
Tables as rows
Table to JSON rows reads the table you choose and uses its first row as the keys. Every value is text. Empty header cells become column_1, column_2 and so on, repeated headers get _2 and _3, and cells with colspan or rowspan are repeated. Turn off the header option to get an array of arrays instead.
Error messages and what to do
| Message | What it means | Fix |
|---|---|---|
No HTML found to convert | The input has no elements or text. | Paste some markup. |
No <table> with rows found in the HTML | Table to JSON rows needs a table. | Include a <table> with rows, or use the tree button. |
Questions people ask
How do I convert HTML to JSON?
Paste the HTML and press HTML to JSON tree. Every element becomes an object with its tag name, attributes and children. Text appears as plain strings in the children array.
Can it parse an HTML table to JSON?
Yes. Press Table to JSON rows. The first row supplies the keys and each later row becomes an object. Values stay as text, so 12 is "12". Choose another table if the page has several.
Does the tool run scripts in my HTML?
No. The markup is only read as text. Script and style contents appear in the tree as text, and nothing is executed or fetched. The reader runs in the page and needs no browser DOM.
Why is some of my text missing from the tree?
Whitespace-only text between tags is dropped, and text is trimmed. Comments are skipped unless you tick the keep option. If you need exact spacing, check the pre, script, style and textarea elements, which keep theirs.
Is the output the same as a browser DOM?
It is close but not identical. The parser fixes common problems such as unclosed li or p tags, but it does not implement every rule of the HTML standard, so unusual broken markup may nest differently.
About this tool
HTML to JSON tree writes every element as an object with "tag", "attrs" (name and value, with "" for an attribute that has no value) and "children", which holds text strings and further objects. Tag and attribute names are lowercased, character references are decoded, void tags such as <br> have no children, and unclosed tags such as <li> and <p> are closed the way browsers do. Text is trimmed and runs of whitespace collapse to one space (except inside pre, script, style and textarea), and whitespace-only text is dropped. Comments and the doctype are dropped unless you tick the option. Table to JSON rows reads a table into an array of objects keyed by its header row, with every value as text, and repeats cells with colspan or rowspan. It does not run scripts or fetch anything.