String to JSON

Turn ordinary text into valid JSON, whether it is a settings block, a list of values or an escaped string literal.

Text
JSON
Runs locally in your browser

About the String to JSON

Not every string that needs to become JSON is already JSON. A block of key = value settings copied from a properties file, a column of values pasted from a spreadsheet, a comma separated list typed into a ticket: all of them are one edit away from being usable data. This converter recognises those shapes and builds the right structure for each one.

Detection runs first. Text where every line contains an equals sign or a colon becomes an object. Several lines with no separator become an array of strings. A single line containing commas becomes an array of its parts. Text that is wrapped in quotes or full of backslash escapes is treated as a string literal, unescaped, and parsed if a document is hiding inside. When the guess is wrong, pick the shape yourself from the selector and the result rebuilds immediately.

Type conversion is on by default, so true, false, null and anything that looks like a number become real JSON values rather than quoted text. Turn it off when identifiers matter more than types, for example a list of postcodes or product codes with leading zeros that must not be read as numbers. Surrounding quotes on individual keys and values are removed either way.

If your text is already delimited data with a header row, CSV to JSON understands it better, and for something that is nearly JSON but slightly malformed, try JSON Fixer.

How to use

  1. Paste your text on the left. The Sample button loads a block of connection settings.
  2. Leave Input shape on Detect automatically and check the result.
  3. If the structure is not what you wanted, choose the shape explicitly from the selector.
  4. Untick Convert numbers and booleans to keep every value as a string.
  5. Copy the JSON or download converted.json.

Common questions

How does the tool decide which shape my text has?
It looks for a separator on every line first, then for multiple lines, then for commas on a single line, and finally for quotes and backslash escapes.
Why did my product code 00742 become 742?
Number conversion turned it into a numeric value. Untick "Convert numbers and booleans" to keep every value as a string with its leading zeros.
Can it handle values that contain an equals sign?
Yes. Only the first separator on a line splits the key from the value, so a connection string on the right hand side stays intact.
What if my text is already JSON?
Paste it into the JSON Formatter instead. This tool is for text that is not yet JSON, although the literal mode will unwrap a quoted document for you.