How to convert an HTML table to JSON
To convert an html table to json, the tool reads the table cells, takes the header cells as the keys and writes one object per body row. Here is the first table of the Example, a team list with a thousands separator, a decimal and a yes or no column:
[
{
"Name": "Ada Lovelace",
"Role": "Mathematician",
"Seats": 1200,
"Remote": "yes"
},
{
"Name": "Linus",
"Role": "Engineer",
"Seats": 85.5,
"Remote": "no"
},
{
"Name": "Grace Hopper (admiral)",
"Role": "Grace Hopper (admiral)",
"Seats": "",
"Remote": true
}
]Seats became numbers because 1,200 and 85.5 are plain numbers. Remote is true on the last row because the cell says true, while yes and no stay text, since they could mean different things in different tables. The last row used a merged cell, which is explained below. Links keep their text and lose the address.
Pasting a page or copying a table from a browser
You do not have to find the table code. Select a table on a web page, copy it and paste it into the box. The browser puts the table's HTML on the clipboard, and the tool uses that. You can also paste the full source of a page. Every table in it is listed in Tables found, including tables used for layout, so pick the one with your data. Scripts and styles in pasted HTML are never run.
If the pasted text has no table tags but is separated by tabs, as when you copy cells from a spreadsheet, it is read as a table. Respect the terms of the site you copy from.
Four JSON shapes
A list of objects is the usual choice for APIs and code. The others suit different jobs. The same two-row table gives these results:
// List of lists
[["Name","Age"],["Ada",36],["Linus",55]]
// Object of columns
{"Name":["Ada","Linus"],"Age":[36,55]}
// Object keyed by the first column
{"Ada":{"Age":36},"Linus":{"Age":55}}A keyed object is a lookup table, so the first column should be unique. If it is not, repeated values get _2, _3 and so on, and a note says so. Object keys in JavaScript that look like whole numbers, such as 2026, are moved to the front when the JSON is read by a program. That is how the language orders keys and not something the tool changes in the text.
Tables with no header, or two header rows
Keys set to From the header cells uses the cells inside thead or the cells written as th. If the table has none of those, the first row is used and a note says so. From the first row always uses the first row. Generate column1, column2 ignores the text and treats every row as data, which is the right choice for a table with no header at all.
When a table has two header rows, such as a Sales cell spanning Q1 and Q2 above them, the parts are joined with a space. That table gives the keys Sales Q1 and Sales Q2, so no information in the top row is lost. Empty header cells are named column1, column2 and so on by their position.
Merged cells: rowspan and colspan
A cell that spans several rows or columns would shift every later value left if it were read as one cell. The tool places each cell on a grid first, so merged cells keep the columns aligned. Merged cells set to Repeat the value copies the text into every cell it covers. Leave the others empty puts the text in the first cell only. For a table where a cell spans two rows and a last row has one cell spanning both columns, the two settings give:
// Repeat the value
[{"A":"x","B":1},{"A":"x","B":2},{"A":"wide","B":"wide"}]
// Leave the others empty
[{"A":"x","B":1},{"A":"","B":2},{"A":"wide","B":""}]Repeated column names and key style
Two columns can have the same header, and a JSON object cannot hold the same key twice. Many converters let the second column overwrite the first, and the data is lost without a warning. Here Repeated headers adds _2, _3 and so on by default, so tag and tag become tag and tag_2. Group into a list instead gives one key with a list of the values:
[{"tag":["a","b"],"n":1}]Key style can rewrite the header text as camelCase, snake_case or lowercase. First Name becomes firstName or first_name. Characters that are not letters or digits count as word breaks, so a header such as Total ($) becomes total in snake_case.
How numbers, booleans and empty cells are typed
- Numbers: with the US format, 1,200 and -3.5 become numbers and 1,2 stays text. With 1.234,56 selected, 1.200,5 becomes 1200.5.
- Leading zeros: 007 stays text, so codes and ZIP codes are not changed. 0.5 and 0 are numbers.
- Long numbers: a value with more than 15 digits stays text, because JSON numbers cannot hold it exactly.
- Booleans: true and false, in any capitals, become booleans. Yes, no, on and off stay text.
- Empty cells: write empty text, null, or leave the key out of that object.
- Percent and currency signs such as 50% and $5 stay text, because turning them into numbers would drop the unit.
Turn off Numbers and true/false to keep every value as text, which is the safest choice when you will do the typing yourself in code.
Limits and privacy
A table can have at most 200,000 body rows. Larger input is refused with a message. The tool works from the table markup only. It does not read data loaded by scripts after a page opens, so view the source of such a page only after the table is in the page, or copy the table from the rendered page. Cell text is kept, but links, images and formatting are not.
Everything runs in your browser. The HTML is not sent to a server and is not stored. See the Privacy Policy for details.
Related tools
To build a table from JSON, use JSON to HTML Table. If you need a spreadsheet file, HTML Table to CSV writes CSV, and HTML Table to Markdown writes a README table. CSV to HTML Table goes the other way, and JSON Schema Generator can describe the JSON you get here.