A laptop, a phone and a hand writing in a notebook on a wooden desk, banner image on the Code Converter page

ツール / Build suite

Code Converter

Convert data between JSON, YAML, CSV and query-string formats with exact, reversible output

Paste JSON, YAML or CSV and convert between them losslessly - nested JSON becomes dotted YAML keys, CSV becomes typed JSON rows - with the parse errors pointed at, not swallowed.

Open the tool
Screenshot of the Code Converter tool

What it does

Formats in, format out.

Three formats both ways

JSON, YAML (flat and nested) and CSV convert in either direction.

Real parsing

JSON.parse for JSON, indentation-aware YAML reading, quoted-field CSV.

Errors with locations

Bad input names the line, not a silent empty output.

Type fidelity

Numbers, booleans and nulls stay typed through JSON round-trips.

Numbers stay numbers

A value reads as a number only when it fits the strict pattern, so 007 and +5 stay text and 12, -3.5 and 1e3 become numbers.

Null, true and false typed

In YAML, null and a tilde become null, and true and false become booleans, before they reach JSON.

One document only

A leading three-dash line is accepted once. A second document is refused with its line number.

Unsupported YAML refused

Tabs for indentation, anchors, aliases, tags and block scalars each stop the run with a message that names the line.

Duplicate keys caught

A key repeated at the same level is an error, not a silent overwrite.

Quoted CSV fields

Commas, doubled quotes and line breaks inside quotes are read correctly. A header row and one data row are required.

How it works

Paste, pick, copy.

Step 1

Paste your data and pick its format.

Step 2

Pick the target format; conversion runs live.

Step 3

Copy the output.

FAQ

YAML anchors?

Not supported - anchors are flagged as unparseable rather than dropped.

CSV dialects?

Comma with optional quoting; semicolon dialects convert after a find-replace.

Why is the string 123 written with quotes in YAML?

Plain 123 would read back as a number. Strings that look like numbers, booleans, null, yes, no, on or off are quoted so a round trip keeps the type.

Are YAML comments kept?

Full-line comments are skipped and trailing comments after a space are removed. They are not carried into the output.

What does a bad flow collection do?

Only JSON-style square and curly brackets are accepted inside YAML. Anything else stops with a message.

Does my data get uploaded?

No. The parsers are JavaScript in the page and run in the tab.

Open Code Converter

Worked example

Real output, from the tool itself.

This is what Code Converter returned for the example input shown, captured from the tool itself - not a mockup.

You enter

From / To

JSON to YAML

Input

{"service":"api","replicas":3,"tls":true,"endpoints":[{"path":"/users","cache":60},{"path":"/orders","cache":null}],"limits":{"rps":100,"burst":200}}

The tool returns

service: api
replicas: 3
tls: true
endpoints:
  -
    path: /users
    cache: 60
  -
    path: /orders
    cache: null
limits:
  rps: 100
  burst: 200
Try it with your own input

More in the Build suite

Font Pairing LabWebhook TesterPricing Page BuilderLanding Page MakerStatus Page Starter
A laptop, headphones, a camera, a phone and a plant on a white desk, seen from above, banner image on the Code Converter page

Try it now.

Code Converter runs in your browser. No account needed.

Input To Output

Three formats, six directions

JSONYAMLCSVJSONYAMLCSVCode ConverterInOut
InJSONYAMLCSVCode ConverterJSONYAMLCSVOut
Pick what you have and what you want.

Pipeline

How a conversion runs

Read the inputformatParse it into dataWrite the outputformatShow it or show anerror
Read the input formatParse it into dataWrite the output formatShow it or show an error
Everything goes through one data structure in the middle.

Before After

Reading scalar values

YAMLRead asreplicas: 3tls: truecache: nullservice: apinumber 3boolean truenulltext api
YAML to Read asreplicas: 3number 3tls: trueboolean truecache: nullnullservice: apitext api
The same rule applies to YAML values.

Pipeline

Reading CSV

Walk the text onecharacter at atimeInside quotes,keep commas andbreaksA double quoteinside quotes isone quoteA line break endsthe row
Walk the text one character at atimeInside quotes, keep commas andbreaksA double quote inside quotes isone quoteA line break ends the row
A small reader handles quotes properly.

Before After

A quoted cell

CSV rowCells"Smith, Jo",42"say ""hi""",7Smith, Jo and 42say "hi" and 7
CSV row to Cells"Smith, Jo",42Smith, Jo and 42"say ""hi""",7say "hi" and 7
Commas inside quotes stay in the cell.

Spec Sheet

CSV rules

Header rowrequired, plus one data rowValues typedtrue, false, numbersNested valuesJSON inline in the cellRefusednot an array of objects
Header rowrequired, plus one data rowValues typedtrue, false, numbersNested valuesJSON inline in the cellRefusednot an array of objects
Both directions.

Input To Output

JSON to CSV

A JSON arrayof objectsA header fromevery keyfoundOne row perobjectQuoted cellswhere neededTable writerInOut
InA JSON array of objectsTable writerA header from every key foundOne row per objectQuoted cells where neededOut
The JSON must be a list of objects.

Pipeline

Finding the columns

Visit each objectAdd keys not seenyetKeep first-seenorderBlank where anobject lacks a key
Visit each objectAdd keys not seen yetKeep first-seen orderBlank where an object lacks a key
Columns come from all the objects, not just the first.

Before After

Different keys per object

JSONCSV{"a":1,"b":2}{"a":3,"c":4}a,b,c1,2,3,,4
JSON to CSV{"a":1,"b":2}a,b,c{"a":3,"c":4}1,2,3,,4
Missing values become empty cells.

Pipeline

YAML structure

Read each linewith its indentA dash starts alist itemA key and colonstarts a map entryDeeper indentmeans nested
Read each line with its indentA dash starts a list itemA key and colon starts a map entryDeeper indent means nested
Indentation tells the reader what nests inside what.

Spec Sheet

YAML that is supported

Nested maps and lists2-space indentFlow collectionsJSON-style onlyCommentsstrippedQuotessingle and double
Nested maps and lists2-space indentFlow collectionsJSON-style onlyCommentsstrippedQuotessingle and double
A practical subset.

Spec Sheet

YAML that is refused

Tabs for indentrefusedMultiple documentsrefusedTags and anchorsrefusedBlock scalars | and >refused
Tabs for indentrefusedMultiple documentsrefusedTags and anchorsrefusedBlock scalars | and >refused
With a line-numbered reason.

Before After

Errors name the line

YAMLMessagea: b: 1a: 1 a: 2x: |line 2: tabs cannot be usedfor indentationline 2: duplicate key aline 1: block scalars (| and>) are not supported
YAML to Messagea: b: 1line 2: tabs cannot be used forindentationa: 1 a: 2line 2: duplicate key ax: |line 1: block scalars (| and >) arenot supported
The message starts with the line number.

Pipeline

Writing YAML

A map writes key:valueA list writes -itemsNested dataindents two spacesEmpty list is []and empty map is{}
A map writes key: valueA list writes - itemsNested data indents two spacesEmpty list is [] and empty map is{}
The writer builds lines from the data.

Before After

Quoting on output

Text valueIn YAMLyes007a: bhello"yes""007""a: b"hello
Text value to In YAMLyes"yes"007"007"a: b"a: b"hellohello
Text that could be misread is protected.

Input To Output

JSON in

Valid JSONData for YAMLData for CSVJSON readerInOut
InValid JSONJSON readerData for YAMLData for CSVOut
Standard JSON is read with the browser parser.

Input To Output

JSON out

Data from YAMLor CSVPretty printedJSONJSON writerInOut
InData from YAML or CSVJSON writerPretty printed JSONOut
JSON is written with two-space indent.

Before After

Starter example in YAML

JSONYAML{"service":"api","replicas":3,"tls":true}service: apireplicas: 3tls: true
JSON to YAML{"service":"api","replicas":3,"tls":true}service: apireplicas: 3tls: true
JSON on the left becomes YAML on the right.

Pipeline

When something is wrong

Parser failsOutput box isemptiedRed error lineappearsFix the input andit clears
Parser failsOutput box is emptiedRed error line appearsFix the input and it clears
The output clears and a message appears above it.