Text to JSON converter

Turn plain text into valid JSON: key: value lines become an object, plain lines become an array, or the whole text becomes a single JSON string. The conversion runs in your browser and nothing is uploaded.

Convert to

How it works

  1. Paste your text

    Type or paste the text in the left box, or open a .txt file. No text to hand? Click Example.

  2. Instant result

    The result appears as you type. Change the options and see straight away what changes.

  3. Copy or download

    Copy the result with one click, save it as a file or use it as input for a next step.

Three modes

  • Object (key: value): name: One café and seats: 24 become {"name": "One café", "seats": 24}.
  • List (each line): every line becomes an item in a JSON array.
  • One JSON string: the entire text, with quotes and line breaks escaped, ready to paste into JSON or source code.

With Recognise numbers, true, false and null on (the default), 24 becomes a number and true a boolean instead of a string.

Example

The text name: One café, open: true, seats: 24 and city: London becomes an object with four keys: a string, a boolean, a number and another string. As a list, the lines one, two, 3 and true become ["one", "two", 3, true].

Uses

Preparing configuration values, test data and translation strings from notes, and embedding a long text with quotes and line breaks in a JSON file without escaping by hand.

To make JSON readable, use the JSON formatter. To convert JSON back to plain text, use JSON to text. To join lines into one before you convert, see join lines.

Frequently asked questions

How do I turn a block of text into a JSON string?

Choose *One JSON string*. Quotes, backslashes and line breaks are escaped, so `He said "hi"` plus a second line becomes `"He said \"hi\"\nnew line"`, ready to paste into JSON or source code.

How are numbers and booleans treated?

With *Recognise numbers, true, false and null* on, which is the default, `24` becomes the number 24 and `true` the boolean. Turn it off to keep everything as text.

What is the format for an object?

One `key: value` pair per line, such as `name: One café`. The result is an object with those keys, and the note tells you how many keys it has.

Where does the list come from?

Choose *List (each line)* and every line becomes one item in a JSON array, with numbers and true or false recognised if the option is on.