Data · verktøy

CSV til JSON-konverterer

Lim inn CSV-data med en overskriftsrad og gjør dem om til en JSON-matrise.

Kjøres i nettleseren. Ingen opplasting.

The first row becomes the JSON keys.

Om verktøyet

CSV til JSON-konverterer sem complicação.

Anførte kommaer, linjeskift og escape-anførselstegn håndteres lokalt for vanlige regnearkeksporter.

Veiledning

Slik bruker du CSV til JSON-konverterer

This page turns pasted CSV text into a JSON list. The first row is used as the names of the fields, and every other row becomes one object in the list. It reads commas as separators and understands double-quoted cells that contain commas, line breaks or quotes. It does not open files, guess numbers or dates, or accept semicolon or tab separators, so every value in the result is a text string.

Slik gjør du

  1. Paste your CSV into the CSV data box. Put the column names in the first row and at least one row of data under it.
  2. Press Convert to JSON. The JSON appears in the result box, with two spaces of indent, and a message says how many rows were converted.
  3. Press Copy result to copy the JSON. If you see an error, read the message and fix the CSV. Press Clear to empty both boxes.

Eksempler

A plain table

Du skriver inn
CSV-data
name,age,city Ada,36,London Bob,41,Paris
Du får
JSON
Navn: Ada; Alder: 36; By: London; Navn: Bob; Alder: 41; By: Paris

Two data rows give two objects. The age is written as the text "36" inside quotes, not as the number 36, because the tool never changes a value's type.

Kjørt med verktøyets egen kode.

Quotes, a comma and a line break inside cells

Du skriver inn
CSV-data
name,note "Smith, Jo","said ""hi""" Lee,"line one line two"
Du får
JSON
Navn: Smith, Jo; Notat: said "hi"; Navn: Lee; Notat: line one line two

A cell wrapped in double quotes may hold a comma, and a pair of double quotes inside it stands for one quote mark. A line break inside quotes stays in the value and shows as \n in the JSON.

Kjørt med verktøyets egen kode.

Repeated and missing headings

Du skriver inn
CSV-data
a,a, 1,2,3
Du får
JSON
a: 1; a_2: 2; Kolonne 3: 3

The second a is renamed a_2 so no value is lost, and the empty third heading is named column_3. A row shorter than the heading row would fill the missing fields with empty text.

Kjørt med verktøyets egen kode.

Når det er nyttig

  • Turn a small spreadsheet export into JSON to use in a script or a mock API.
  • Prepare test data for a web page from a list typed in a spreadsheet.
  • Check how quoted cells and embedded commas are read before sending data to another system.
  • Convert a short list of settings kept as CSV into a JSON file for an app.

Begrensninger

  • Only the comma is read as a separator. A semicolon file such as 'name;age' produces a single field with the whole line as its name.
  • Every value stays text. Numbers, true, false and empty cells are not converted, and text like 007 keeps its leading zeros.
  • Extra cells in a row that has more cells than the heading row are dropped without a warning, and blank lines are skipped.
  • The code sets no size limit for pasted text. A very large paste can make the page slow, so use another tool for large files.

Tips

  • If your file uses semicolons or tabs, change the separators to commas in a text editor before pasting.
  • Keep your original CSV, because the tool only shows the JSON and does not change what you pasted.
  • Scan the JSON for a field named with a column_ prefix, since that means a heading was empty.

Kilder

Vanlige spørsmål

Sobre CSV til JSON-konverterer.

How do I convert CSV to JSON?

Paste the CSV with column names in its first row, then press Convert to JSON. Each following row becomes one object whose keys are the column names, and all the objects are collected into one list.

Are commas inside quoted cells supported?

Yes. A cell in double quotes can contain commas, line breaks and doubled quote marks. The tool treats a quote as the start of a quoted cell only when it is the first character of that cell; a quote in the middle of plain text is kept as ordinary text.

Why are my numbers shown in quotes?

The tool keeps every value as the exact text from the CSV. It does not decide whether something is a number, a date or a yes or no. If you need numbers, change the types in a script after copying the JSON.

What happens if a quote is not closed?

The tool stops and shows an error that a quoted field was not closed, and the result box stays empty. Fix the quotes in the CSV, for example by adding the missing closing quote, and press Convert to JSON again.

Can I upload a CSV file?

This page has a text box only, so you paste the CSV rather than choose a file. For files, use a tool that has a file picker. Pasted text is converted in your browser and is not sent to a server.

What if two columns have the same name?

The tool keeps both by renaming the later ones with a number, for example a and a_2. Empty headings get names like column_3. This avoids losing data, but you may want to rename the keys afterwards.

Hvordan bruker du CSV til JSON?

Lim inn CSV-data med en overskriftsrad og gjør dem om til en JSON-matrise.

Lastes dataene mine opp til en server?

Nei. Behandlingen skjer i nettleseren din, og opplysningene dine lastes ikke opp.