piapia123
en

Matrix and JSON Converter

Convert

Everything runs locally in your browser — nothing is uploaded

Input
Drop a file here to load its contents
Output

Turn matrix text (one row per line, the kind you copy out of Excel, MATLAB or NumPy) into a JSON array of arrays, or render a JSON array back into an aligned matrix. Unlike the table converter on this site, this keeps numbers as numbers — the output is `[[1,2],[3,4]]`, not `[["1","2"],["3","4"]]`. For a matrix you intend to compute with, whether the values are strings or numbers decides whether it can be used at all. The trade-off is that a cell like `007` becomes `7`; if you need the leading zeros preserved, use the table converter instead. Rows of differing length are reported by line number rather than padded or truncated, because a padded zero or a dropped value makes the downstream calculation wrong in a way the data itself never shows.

Features

  • Both directions: matrix text to a JSON array, and a JSON array back to matrix text
  • Numbers stay numbers rather than becoming strings
  • Commas, tabs, whitespace and semicolons all work as delimiters, with automatic detection
  • Direction is detected too: a leading [ means JSON, anything else means matrix text
  • Ragged rows are reported with the line number of the first mismatch
  • Rendered matrices align their columns — numbers right, text left, measured by display width so CJK lines up
  • A one-dimensional JSON array is treated as a single row rather than an error
  • Round-trips: text to JSON and back leaves the numbers unchanged
  • Accepts CRLF and LF input
  • Everything runs locally in the browser; your data is never uploaded

How to use

  1. Paste the matrix text or the JSON array
  2. The direction usually needs no choosing — a leading [ is read as JSON
  3. Pick a delimiter only if detection gets it wrong
  4. Copy the result

FAQ

How is this different from the table converter?
The table converter handles tables with headers and always writes values as strings, because a leading zero like `007` is lost the moment it becomes a number. This tool handles headerless numeric matrices and writes values as numbers, since the output is meant to be computed with — strings or numbers decides whether it can be used directly. So: to preserve the original text use the table converter; to get a numeric matrix you can compute on, use this one.
Why did 007 turn into 7?
Because in a numeric matrix that cell is read as the number 7. It is the unavoidable cost of the "numbers stay numbers" rule — the two cannot both hold, since `7` and `"007"` are different JSON values. For identifiers, postcodes and employee numbers, use the table converter, whose output is always strings.
What happens if the rows have different lengths?
It reports an error naming which row disagrees with row 1. A matrix is rectangular by definition, and padding or truncating silently changes the data: a padding zero skews the average, a dropped value removes an entire column, and neither is visible in the data itself. The same applies on the JSON side — a shape like `[[1,2],3]`, half arrays and half scalars, is reported because it is not a valid shape at all.
Why are columns not padded when the delimiter is a tab?
Because a tab already aligns things, and adding spaces on top makes the result shift width between editors — every editor has its own tab stop. With the other delimiters the columns are padded by display width (a CJK character counts as two), with numbers right-aligned and text left-aligned, so the magnitude of a column of numbers is visible at a glance.
Is my data uploaded?
No. The conversion happens entirely in browser memory; the page makes no requests and works offline.

Related tools