All tools
Free · Private · No upload

Convert JSON to LaTeX Table Online

Turn a JSON array into a LaTeX tabular for a report or paper. The JSON is parsed in your browser and never uploaded.

Drop a CSV or Excel file here

CSV · XLSX · XLS · XLSM · XLSB

or paste your data below

How to convert JSON to a LaTeX table

Three steps from benchmarks.json to LaTeX.

1. Paste the JSON

Paste JSON or drop a .json file. Arrays, keyed objects and JSON Lines all work.

2. Check it in the grid

Drop columns with nested JSON or long strings: in LaTeX they make a table wider than the page.

3. Choose environment and rules

tabular or longtable, booktabs rules or grid lines, alignment and escaping; copy the code or download data.tex.

Example: JSON in, LaTeX out

Benchmark timings saved as a 2D array, header row first, with an underscore in a column name.

benchmarks.json
[
  ["dataset", "rows", "time_ms"],
  ["small", 1000, 4.2],
  ["large", 100000, 388.9]
]
data.tex (default options)
\begin{tabular}{|l|l|l|}
\hline
dataset & rows & time\_ms \\
\hline
small & 1000 & 4.2 \\
large & 100000 & 388.9 \\
\hline
\end{tabular}

The 2D array is used as is: the first inner array is the header. time_ms is written as time\_ms, and 100000 is printed without a thousands separator.

What changes between JSON and LaTeX

Escaping

& % $ # _ { } ~ ^ are escaped, so the value time_ms is written as time\_ms. Untick Escape special chars only when the cells already contain LaTeX, such as math in $...$.

Alignment

Left, Center or Right sets l, c or r for every column. These columns don't wrap text, so a long cell widens the table; use p{4cm} in the spec by hand for wrapping columns.

2D array used as is

An array of arrays is taken row by row: the first inner array is the header and every value becomes cell text.

When to convert JSON to LaTeX

JSON to LaTeX in JavaScript

JSON needs no parser: JSON.parse gives you the data. Then special characters are escaped and cells joined with &.

import { readFile } from 'node:fs/promises';

const [header, ...rows] = JSON.parse(await readFile('benchmarks.json', 'utf8'));

const map = { '\\': '\\textbackslash{}', '~': '\\textasciitilde{}', '^': '\\textasciicircum{}' };
const esc = (v) => String(v ?? '').replace(/[\\&%$#_{}~^]/g, (c) => map[c] ?? '\\' + c);
const line = (cells) => cells.map(esc).join(' & ') + ' \\\\';
console.log([`\\begin{tabular}{|${header.map(() => 'l').join('|')}|}`, '\\hline', line(header), '\\hline',
  ...rows.map((row) => line(header.map((_, i) => row[i]))), '\\hline', '\\end{tabular}'].join('\n'));

TabularJS reads spreadsheet files, not JSON; JSON.parse is all JSON needs.

npm install tabularjs MIT licensed

Frequently asked questions

Can I right-align the numbers?

Choose Right in the Align menu to right-align every column. For mixed tables, edit the column spec by hand, for example {|r|l|l|l|l|}.

Why is 100000 not written as 100,000?

Values are copied as they are in the JSON. Use siunitx (\num{100000}) or edit the cells if you want thousands separators.

Why do I get “This JSON doesn’t contain a table”?

The JSON is valid, but no table was found in it: for example a single object of plain values, or an array of strings. Wrap your objects in an array, or paste the array part of the response.

My table is wider than the page. What can I do?

Shorten headers in the grid, switch long text columns to p{width} by hand, or wrap the tabular in \resizebox{\textwidth}{!}{...} from the graphicx package.

Does benchmarks.json get uploaded when I convert it to LaTeX?

No. The JSON is parsed in your browser and never uploaded.