Convert Markdown Tables, HTML Tables, and JSON: How It Works

PublishedToolMarkdown ↔ HTML ↔ JSON Table Cross Converter

Contents
  1. Where Markdown tables get stuck on the way to HTML or JSON
  2. Moving between the three formats by hand: there's only one rule
  3. Common sticking points
  4. Wrapping up
  5. Frequently asked questions

A Markdown table (pipe syntax), an HTML <table> tag, and a JSON array of objects differ only in how they express data — the header row and the value rows are the same. This post explains how the three formats map onto each other, and what actually happens when the column counts don't match or the header separator line is missing.

Summary ① The first line of a Markdown table is the header row, and the second line is treated as a separator only if it contains - characters. ② HTML uses the <th>/<td> cells inside <tr>, and JSON uses the keys of the first object as the header row. ③ If the number of cells varies from row to row, the converter fills in blanks or drops the extras automatically — you don't have to line them up yourself.

Where Markdown tables get stuck on the way to HTML or JSON

It's a common spot to be in: the blog post uses a Markdown table, but the site needs HTML. Or an API hands you a JSON array and you need a Markdown table for the docs. One or two tables you can move by hand, but once you're past a few dozen rows, counting pipe (|) positions or opening <td> tags one at a time is a recipe for typos.

Moving between the three formats by hand: there's only one rule

All three formats split the data into one header row and multiple value rows. The only difference between formats is the syntax that wraps those two chunks.

  • Markdown → HTML: turn each cell in the first line into a <th>, turn each cell in the following lines (skipping the separator line) into a <td>, and wrap each line in <tr>.
  • HTML → Markdown: turn one <tr> into one line, list its <td>/<th> values separated by |, then add a separator line of the form |---|---| right below the header row.
  • JSON → Markdown/HTML: the key names of the first object in the array become the header row, and each object's values become one row in that key order.

With just these three rules you can convert as many tables as you like by hand, but the more rows there are, the more mistakes creep in. You can try a tool below that applies the same rules to whatever you paste and shows you the other two formats at once.

Markdown ↔ HTML ↔ JSON Table Cross Converter

Paste your Markdown table source, HTML tags, or JSON data into the input field and see it instantly as the other table formats.

Common sticking points

SituationHow it's actually handled
No separator line (-) on the second line of the Markdown tableIt isn't recognized as a separator, so the second line goes in as just another data row
Rows have different cell countsCells missing relative to the header row are filled with empty strings; extras are dropped
The HTML splits a header row (<th>) from body rows (<td>)The header row is detected correctly, but the <tr> that held the header can be added again as the first data row, so check whether the first output row duplicates the header text
Objects in the JSON array have different keysOnly the first object's keys are used as the header row, and values for keys that exist only in other objects don't appear in the output

Wrapping up

The three formats are the same structure — a header row plus value rows — written in different syntax. Follow that mapping when you convert by hand, and a converter applies it automatically to every input and shows you the result. Still, for the spots that trip people up in practice — a missing header separator, mismatched cell counts, a duplicated HTML header row — it's safer to eyeball the output against the table above.

Markdown ↔ HTML ↔ JSON Table Cross Converter

Paste your Markdown table source, HTML tags, or JSON data into the input field and see it instantly as the other table formats.

Frequently asked questions

Can I use merged cells (rowspan, colspan) in a table?

All three formats handle only a header row plus value rows, so merged cells aren't supported. You need to unmerge them, fill each cell with its value, and then paste it in.

The output repeats my header row. What do I do?

If your HTML input has a separate <tr> containing <th> cells for the header, that line can also come through again as a data row (see the table above). Just delete that line from the output.

Can a cell contain a line break or a | character?

In Markdown, | is the cell separator itself, so a pipe character inside a cell splits the table in the wrong place. Line breaks are also read as new rows and break the table, so it's safest to leave both out of your values.

This article was adapted from our Korean original. Read the Korean original

Related articles

  1. Merge Text Files Without Broken Encoding (UTF-8 vs EUC-KR)Combine split TXT files in your browser, set delimiters and file headers, and see why merged text breaks when the source is EUC-KR instead of UTF-8.
  2. Mock JSON data: how to generate dummy records for API testsBuild fake JSON arrays with sequential IDs, UUIDs, names, emails, random numbers, and dates, plus how to simulate network latency in API tests.
  3. Morse Code Sound Formula and Web Audio API Frequency GuideLearn the standard Morse timing formula (dot 1 unit, dash 3 units) and how to synthesize sine wave beeps in the browser with the Web Audio API.
  4. Morse Code Decoding: Alphabet Chart and How to TranslateSee the one-to-one mapping of letters, numbers and symbols to dots and dashes, plus the rules for separating letters and words when you encode or decode.
  5. Initials from English Names: Rules, Order, and CapitalizationHow to pull initials from a full English name: which word is the family name, how to set capitals, and when to use periods. Includes middle name cases.
  6. Binary, Octal, Decimal, Hex Conversion: Formulas and CodeLearn how binary, octal, decimal, and hexadecimal convert into each other, plus JavaScript toString and parseInt examples and why floats drift.

Related tools