---
title: "CSV to JSON Converter"
description: "Free CSV to JSON converter: paste CSV or upload a file, get a pretty JSON array or NDJSON with numbers and booleans inferred. Runs in your browser."
url: "https://jamsql.com/tools/csv-to-json/"
html_url: "https://jamsql.com/tools/csv-to-json/"
generated: "2026-07-22T23:18:48.036Z"
---

# CSV to JSON Converter

Paste CSV or TSV — or upload a file — and get a pretty-printed `JSON` array or `NDJSON`, with numbers and booleans inferred per column instead of left as strings. Everything runs in your browser; nothing is uploaded.

Format JSON arrayNDJSON (one object per line)  First row is headers  Empty fields as null  Pretty-print

Your CSV data Or upload a file 

Generated JSON

Copy to clipboard Download

NDJSON is always compact — one JSON object per line, no surrounding array or commas between rows — so "Pretty-print" is ignored while this format is selected.

!function(){var e=function(e){return document.getElementById(e)},t=e("tool-input"),n=e("tool-output"),o=e("tool-status"),r=e("tool-file"),i=e("tool-format"),a=e("tool-headers"),l=e("tool-nulls"),u=e("tool-pretty"),c=e("tool-ndjson-note"),s=e("tool-copy"),d=e("tool-download"),f=!1,m=null;function h(e,t,n){if(void 0===e||""===e)return"int"===t||"bigint"===t||"dec"===t||"bool"===t||n?null:"";if("int"===t||"bigint"===t){var o=Number(e);return Number.isSafeInteger(o)?o:e}if("dec"===t){var r=Number(e);return isFinite(r)?r:e}return"bool"===t?/^true$/i.test(e):e}function v(e,t){var n={text:"",rows:0,columns:0,error:"",warning:""};if(!/\\S/.test(e))return n;var o=function(e){for(var t={",":0,"\\t":0,";":0},n=!1,o=0;o<e.length;o++){var r=e.charAt(o);if(n)'"'===r&&('"'===e.charAt(o+1)?o++:n=!1);else if('"'===r)n=!0;else{if("\\n"===r)break;void 0!==t\[r\]&&t\[r\]++}}var i=",";return t\["\\t"\]>t\[i\]&&(i="\\t"),t\[";"\]>t\[i\]&&(i=";"),i}(e),r=function(e,t){for(var n=\[\],o=\[\],r="",i=!1,a=1,l=1,u=0;u<e.length;u++){var c=e.charAt(u);i?'"'===c?'"'===e.charAt(u+1)?(r+='"',u++):i=!1:("\\n"===c&&a++,r+=c):'"'===c?i=!0:c===t?(o.push(r),r=""):"\\n"===c||"\\r"===c?("\\r"===c&&"\\n"===e.charAt(u+1)&&u++,o.push(r),r="",a++,1===o.length&&""===o\[0\].trim()||n.push({f:o,line:l}),o=\[\],l=a):r+=c}return(""!==r||o.length>0)&&(o.push(r),1===o.length&&""===o\[0\].trim()||n.push({f:o,line:l})),n}(e,o);if(0===r.length)return n;var i=t.headers?r\[0\]:null,a=t.headers?r.slice(1):r,l=(i||r\[0\]).f.length,u=\[\],c=0,s=0;a.forEach(function(e){e.f.length!==l?(s++,c||(c=e.line)):u.push(e)}),s&&(n.error=s+" row"+(1===s?"":"s")+" skipped — field count differs from "+(t.headers?"header":"first row")+" ("+l+" expected); first at line "+c+"."),u.length>JamSqlGen.ROW\_CAP&&(u=u.slice(0,JamSqlGen.ROW\_CAP),n.warning="Showing the first "+JamSqlGen.ROW\_CAP+" rows — for bigger files, convert in chunks.");var d=function(e,t,n,o){var r=JamSqlGen.columnNames(e?e.f:\[\],!!o.headers,n),i=JamSqlGen.inferColumns(t,n);return t.map(function(e){for(var t={},a=0;a<n;a++)t\[r\[a\]\]=h(e.f\[a\],i\[a\].kind,!!o.emptyAsNull);return t})}(i,u,l,t);return"ndjson"===t.format?n.text=d.map(function(e){return JSON.stringify(e)}).join("\\n"):n.text=t.pretty?JSON.stringify(d,null,2):JSON.stringify(d),n.rows=u.length,n.columns=l,n}function p(){var e="ndjson"===i.value;c.hidden=!e,u.disabled=e;var r=v(t.value,{headers:a.checked,emptyAsNull:l.checked,format:i.value,pretty:u.checked});if(n.textContent=r.text,!r.text)return o.textContent="",void o.classList.remove("tool-error");var s=r.rows+" row"+(1===r.rows?"":"s")+", "+r.columns+" column"+(1===r.columns?"":"s"),d=\[\];r.error&&d.push(r.error),r.warning&&d.push(r.warning),o.textContent=d.length?s+" · "+d.join(" "):s,o.classList.toggle("tool-error",d.length>0),!f&&window.umami&&"function"==typeof window.umami.track&&(f=!0,window.umami.track("tool-csv-to-json-generate",{format:i.value}))}function g(){m&&clearTimeout(m),m=setTimeout(p,250)}\[t,i,a,l,u\].forEach(function(e){e.addEventListener("input",g),e.addEventListener("change",g)}),r.addEventListener("change",function(){var e=r.files&&r.files\[0\];if(e){var n=new FileReader;n.onload=function(){t.value=String(n.result),p()},n.onerror=function(){o.textContent="Could not read that file.",o.classList.add("tool-error")},n.readAsText(e)}}),s.addEventListener("click",function(){var e=n.textContent;if(e){var t=function(){s.dataset.copied="true",s.textContent="Copied!",setTimeout(function(){delete s.dataset.copied,s.textContent="Copy to clipboard"},1500)};if(navigator.clipboard&&navigator.clipboard.writeText)navigator.clipboard.writeText(e).then(t);else{var o=document.createElement("textarea");o.value=e,document.body.appendChild(o),o.select(),document.execCommand("copy"),document.body.removeChild(o),t()}}}),d.addEventListener("click",function(){var e=n.textContent;if(e){var t="ndjson"===i.value,o=new Blob(\[e\],{type:t?"application/x-ndjson":"application/json"}),r=URL.createObjectURL(o),a=document.createElement("a");a.href=r,a.download=t?"data.ndjson":"data.json",document.body.appendChild(a),a.click(),document.body.removeChild(a),setTimeout(function(){URL.revokeObjectURL(r)},1e3)}})}()

## How column types are decided

JSON has no notion of "a column" — it's just values — so the converter scans *every* value in every CSV column first, the same type-inference pass used by the [CSV to SQL converter](/tools/csv-to-sql/), and decides a type per column rather than per cell:

-   A column where every non-empty value parses as a whole number or decimal is emitted as JSON `number`.
-   A column where every non-empty value is exactly `true` or `false` is emitted as JSON `boolean`.
-   Everything else — including dates, since JSON has no native date type — is emitted as a JSON `string`, exactly as written in the CSV.
-   If even a single value in an otherwise-numeric column doesn't parse (an `N/A`, a stray label), the whole column falls back to strings rather than dropping or corrupting that one value.
-   Values with leading zeros, like zip codes, are left as strings — parsing `"007"` as the number `7` would silently destroy the zeros.

Very large integers (beyond JSON's safe 253 range, which `Number.isSafeInteger` enforces) are kept as strings instead of numbers, since converting them would silently lose precision — the same failure mode as pasting a 19-digit ID into a spreadsheet and watching the last few digits turn to zeros.

## JSON array vs. NDJSON

A **JSON array** wraps every row as an object inside a single `[ ... ]` array — one JSON document, valid input for `JSON.parse()`, most REST APIs, and config files. **NDJSON** (newline-delimited JSON) drops the surrounding array and the commas between rows, writing one complete JSON object per line instead. Streaming tools, log pipelines, and bulk loaders — the BigQuery/Snowflake JSON loaders, the Elasticsearch/OpenSearch bulk API, `jq -c` — prefer NDJSON because each line can be read and parsed independently, without holding the whole file in memory.

This tool infers types from the CSV text alone; it doesn't know your real destination schema. Treat the output as a solid first draft — for a strict, versioned mapping from spreadsheet columns to typed fields, define the target shape explicitly rather than relying on inference for anything you'll depend on in production.

## Frequently asked questions

### How do I convert a CSV file to JSON?

Paste CSV into the converter above, or click "Upload a file" to load a `.csv/.tsv` file from disk. The first row is treated as column headers by default, the delimiter — comma, tab, or semicolon — is detected automatically, and the JSON output updates as you type. Copy it or click Download to save a `.json/.ndjson` file. Everything runs locally in your browser.

### What's the difference between a JSON array and NDJSON?

A JSON array wraps every row as one object inside a single `[ ... ]` array — the whole thing is one JSON document, which is what most "give me JSON" APIs and config files expect. NDJSON (newline-delimited JSON) writes one JSON object per line with no surrounding array or commas between rows, which streaming tools, log pipelines, and bulk-loaders (BigQuery, Elasticsearch bulk API, `jq -c`) prefer because each line can be parsed independently without reading the whole file into memory.

### How are column types decided — numbers, booleans, or strings?

Every value in every column is scanned first. If every non-empty value in a column parses as a number, the whole column is emitted as JSON numbers; if every value is `true/false`, it's emitted as JSON booleans. If even one value in the column doesn't fit, the entire column falls back to JSON strings, so a column that's 99% numeric but has one `N/A` stays a string column rather than silently dropping that row's value. Dates are kept as strings, since JSON has no native date type.

### How are empty CSV fields handled?

By default empty fields become JSON `null`. Uncheck "Empty fields as null" to emit empty strings (`""`) for text columns instead — empty values in a numeric or boolean column are always `null`, since `""` is not a valid JSON number or boolean.

### How many rows can I convert?

The converter builds JSON for up to 5,000 rows. If you paste or upload more, it converts the first 5,000 and shows a warning instead of silently truncating. For larger files, process them in chunks or use a script-based CSV-to-JSON conversion instead of a browser tool.

### Is my data uploaded to a server?

No. The converter is plain JavaScript running entirely in your browser — pasted text and uploaded files are read locally, and the page makes no network requests with your data. You can disconnect from the internet after the page loads and it keeps working.

## Need to query that data instead of just converting it?

Jam SQL Studio is a free desktop SQL client for SQL Server, PostgreSQL, MySQL, Oracle, and SQLite — import CSV, XLSX, and JSON files into a real table with a guided wizard, then browse, filter, and export the results in any format.

[Download Free](/#download) [Table Explorer Docs](/docs/table-explorer/)

Free for personal use • No account required • Mac, Windows, Linux

## More free SQL tools

[

### All Free SQL Tools

The full collection — formatters, converters, and generators for everyday SQL work.

](/tools/)[

### CSV to SQL Converter

Turn CSV or spreadsheet data into INSERT statements or a CREATE TABLE script.

](/tools/csv-to-sql/)[

### Excel to SQL Converter

Upload an .xlsx workbook and get INSERT statements or a CREATE TABLE script with inferred column types.

](/tools/excel-to-sql/)[

### SQL Formatter

Format and beautify SQL with dialect-aware rules for T-SQL, PostgreSQL, MySQL, PL/SQL, and SQLite.

](/tools/sql-formatter/)