How to Convert a List to a JSON Array Online

You have a list of names, IDs, or tags and need them as a JSON array for an API payload, a config file, or a test fixture. Typing quotes and commas around dozens of values by hand is slow and one missing comma breaks the whole thing. Paste the list here and it converts instantly.

Convert your list now. Free, no account needed.

Open List Format Converter →

How to do it

  1. Paste your list into the converter. One value per line.
  2. Select JSON Array from the format dropdown.
  3. Turn on Number Detect if your list is numeric. IDs and quantities come out as JSON numbers instead of quoted strings.
  4. Choose Pretty Print or compact, then copy.

A list like this:

apple
banana
cherry

becomes, with Pretty Print on:

[
  "apple",
  "banana",
  "cherry"
]

or, with Pretty Print off:

["apple","banana","cherry"]

Numbers vs. strings

By default every line is treated as a string, so a list of IDs comes out as ["101", "102", "103"]. That's valid JSON, but if the field expects actual numbers - a database ID, a price, a quantity - a quoted string can fail validation or cause a type mismatch when the array is parsed back.

Turn on Number Detect and any line that's purely numeric (integers, decimals, or values in scientific notation) is output unquoted: [101, 102, 103]. Lines that aren't numeric - a name, an email, a code with letters in it - are left as quoted strings either way, so it's safe to leave on even for mixed data.

Compact vs. pretty-printed

  • Pretty-printed (Pretty Print on) - one item per line with two-space indentation. Easier to read, easier to diff in version control, and the format most people expect when pasting into a code file.
  • Compact (Pretty Print off) - the whole array on one line. Useful for pasting into a URL query parameter, an environment variable, or a single-line config value where whitespace and line breaks aren't welcome.

Both are valid JSON and parse identically - the difference is purely formatting.

Special characters are escaped automatically

If a line in your list already contains a double quote, a backslash, or a line break inside a quoted field, the converter escapes it correctly so the result stays valid JSON. You don't need to manually add backslashes or worry about breaking the array - paste your data as-is.

Going the other way: JSON array back to a plain list

Paste a JSON array into the input box and the tool detects it automatically, whatever format the dropdown is currently set to. Each array element becomes one line, with quotes stripped, ready to use as a plain list, feed into another tool, or edit further.

Need other formats from the same list?

SQL IN clause, Markdown bullets, HTML list, CSV row: 21 formats, same tool.

Open List Format Converter →

Frequently Asked Questions

How do I convert a list to a JSON array?
Paste your list (one item per line) into the List to Format Converter, select JSON Array from the format dropdown, and copy the result. Each line becomes one array element.
How do I get numbers instead of quoted strings in the array?
Turn on Number Detect. Any line that parses as a plain number (like 42 or 3.14) is output without quotes as a JSON number. Lines that aren't numeric stay as quoted strings.
Can I get compact JSON instead of pretty-printed?
Yes. Toggle off Pretty Print for a single-line array like ["apple","banana","cherry"] instead of one item per line with indentation. Compact is useful for pasting into a URL or a config value; pretty-printed is easier to read and diff.
What happens to quotes or special characters already in my list?
They're escaped automatically. A line containing a double quote or backslash gets properly escaped so the output is valid JSON you can paste directly into code - you don't need to escape anything yourself first.
Can I convert a JSON array back to a plain list?
Yes. Paste a JSON array into the input and the tool auto-detects it, converting it back to one item per line. This also works with the tool set to any other format - it detects JSON, HTML lists, SQL IN clauses, and more automatically.
Does this work with nested arrays or objects?
No - this tool is built for flat lists, one value per line. If your JSON has nested objects or arrays, you'll need a dedicated JSON editor or a script to flatten it first.
Is this the same as JSON.stringify() in JavaScript?
Functionally yes, for a flat array of strings or numbers - the output is standard JSON and will parse identically. The difference is you don't need to open a console or write any code; paste and copy.
Can I get other formats from the same list?
Yes. The same input works for a SQL IN clause, Markdown bullets, an HTML list, CSV, and 17 other formats - switch the dropdown without re-pasting anything.

Share this tool

Featured on ToolDirs
© 2026 ListDiff

Free online list and text processing tools.