انتقل إلى المحتوى
NeedToConvert

تحويل CSV إلى JSON

الصق CSV أو افتح ملفاً لتحصل على JSON فوراً، مع بقاء الأصفار البادئة والمعرّفات الطويلة كما هي.

  • مجاني
  • خاص
  • بلا تسجيل
يعمل على جهازك. لا يُرفع أي شيء تكتبه.

CSV is the lowest common denominator of data exchange: every spreadsheet, database and analytics tool can export it, yet almost nothing on the web consumes it directly. APIs, front-end code, NoSQL imports and test fixtures want JSON. This converter turns a CSV export into a JSON array while you paste it, with one object per row and the header cells as keys.

Paste the text or open a .csv, .tsv or .txt file of up to 10 MB. The delimiter is detected for you, numbers and booleans become real JSON types, and dotted column names such as address.city can be rebuilt into nested objects. Parsing happens in JavaScript inside this tab, so a customer list or a database dump never travels to a server.

How CSV maps to JSON

CSV has no type system. RFC 4180, the closest thing it has to a standard, only describes records separated by line breaks, fields separated by commas, and double quotes around any field that contains a comma, a quote or a line break, with an inner quote written twice. Every value is text, and whether 42 is a quantity or a product code is up to the reader, while JSON distinguishes strings, numbers, booleans, null, arrays and objects.

Reading follows RFC 4180: quoted fields may contain the delimiter and line breaks, doubled quotes become one quote, and LF, CRLF or CR line endings all work. Like spreadsheet apps, it is lenient: a stray quote inside an unquoted field is kept as text, and an unclosed quote gives a warning with its line number rather than a failure. A leading UTF-8 byte order mark, which Excel writes, is removed so the first key stays clean.

Typical reasons to convert CSV to JSON

Seeding a database or an API

mongoimport, Firebase, Elasticsearch bulk loaders and most REST endpoints accept JSON arrays. Exporting a sheet as CSV and converting it here gives you a payload you can post or import directly, with numbers already typed.

Fixtures and mock data for front-end work

Sample content often lives in a spreadsheet, while the developer needs a JSON file for a React component or a Storybook story. Converting the CSV saves hand-writing hundreds of objects.

Inspecting an export before scripting it

Seeing a CSV as JSON quickly reveals whether the header row is clean, which columns are empty and how quoting was handled, before you write a parser in Python or Node.js.

Delimiters, types and nesting

With Detect automatically selected, the tool samples up to 50 records from the first 64 KB and tries comma, semicolon, tab and pipe, keeping the one that gives the most consistent number of fields; the result appears under the menu and in the Delimiter statistic. Choose one yourself for single-column data or when the guess is wrong. Semicolons are typical of Excel files saved in regions that write decimals with a comma, such as Germany or France.

Detect numbers and booleans turns a cell into a JSON number only when nothing would change. 42, -3.5 and 1e6 become numbers, but 007, 1.50, +5 and anything with more than 15 significant digits stay strings, so ZIP codes, prices with trailing zeros and 18-digit order IDs survive exactly. true, TRUE, false and FALSE become booleans, and an empty cell becomes null. With the switch off, every value is a string.

When First row is the header is on, each later row becomes an object. Blank header cells become column_1, column_2 and so on, a repeated name gets a suffix such as name_2, short rows are padded with null (or empty strings when type detection is off), and extra cells get their own column_N key. Turn the header off for an array of arrays. Nest dotted keys (address.city) turns that column into an address object with a city property, and a numeric segment such as tags.0 builds an array.

طريقة الاستخدام

  1. Paste CSV into the CSV box, load a file with Open file, or press Sample to see an example with quotes and Arabic text.
  2. Leave Delimiter on Detect automatically, or choose Comma, Semicolon, Tab or Pipe.
  3. Set the switches: First row is the header, Detect numbers and booleans, and Nest dotted keys if your columns use dotted names.
  4. Choose 2 spaces, 4 spaces or Minified for the indent, check the Records and Columns counts, then press Copy or Download to save the JSON.

Limits and edge cases

  • Inputs of up to 10,000,000 characters (about 10 MB) are converted. The output box previews the first 200,000 characters, while Copy and Download always include everything.
  • Dates are not recognised: 2024-03-01 stays a string.
  • Decimal commas such as 3,5 and thousands separators such as 1,250 are not treated as numbers and stay strings.
  • Only comma, semicolon, tab and pipe are available as delimiters. Fixed-width files or other separators need cleaning first.
  • Opened files are read as UTF-8, as UTF-16 when they start with a byte order mark, and otherwise as Windows-1252.

الأسئلة الشائعة

How are quotes and commas inside a value handled?

As RFC 4180 describes. A field wrapped in double quotes can contain commas, semicolons and line breaks, and a quote inside it is written as two quotes. In the sample, the field "Lee ""Jay"" Park" becomes the JSON string Lee "Jay" Park, and "Berlin, DE" stays one value.

Why did some numbers stay in quotes?

Because converting them would change them. JavaScript numbers are 64-bit floats with roughly 15 to 17 significant digits, so an ID such as 12345678901234567890 would be rounded, and 0012 would lose its zeros. Such values are kept as strings; convert them in your own code if you are sure they are numeric.

Can I get an array of arrays instead of objects?

Yes. Turn off First row is the header. Every row, including the first, becomes an array of values, a compact shape that charting libraries accept and that suits CSV files without a header.

Is my CSV uploaded, and how big can it be?

Nothing is uploaded; the parser runs in the page. Each input can hold up to 10 million characters, and inputs above roughly 50,000 characters update after a short pause so typing stays smooth.