List to JSON Array
Turn one item per line into a JSON array, with options to trim whitespace, skip blank lines and read numeric lines as numbers.
What the List to JSON Array does
The document is split into lines, each line is optionally trimmed and optionally skipped when blank, and a line matching an integer or decimal pattern is converted to a number when that option is on. Everything else stays a string, including a number with leading zeros, which is usually an identifier.
The output is pretty-printed with two spaces, which is the shape a hand-edited fixture wants.
There is no CSV parsing here: a comma inside a line is part of that item. A line that is only whitespace is kept as an empty string when skipping is off, which is what the option says it does.
How to use it
Paste the lines into the List lines box and set Trim each line, Skip blank lines and Read numbers as numbers.
Press Run and read the JSON array below: one element per surviving line, in order.
Set Read numbers as numbers to no when a numeric-looking line is really an identifier such as a phone number.
Worked example
Input:
1
apple
3.5
Output:
[
1,
"apple",
3.5
]
Why it runs in your browser
The result is produced on this page with JavaScript, so it works offline after the page loads and nothing you enter is sent anywhere.
One JSON array from a pasted list, with three decisions made explicit: whether whitespace is trimmed, whether blank lines are dropped, and whether a line that looks numeric becomes a number.
Every line is a valid item, so there is nothing to refuse — the page's contract is the three options, and each one is visible in the output.
What it does, and what it does not
The document is split into lines, each line is optionally trimmed and optionally skipped when blank, and a line matching an integer or decimal pattern is converted to a number when that option is on. Everything else stays a string, including a number with leading zeros, which is usually an identifier.
The output is pretty-printed with two spaces, which is the shape a hand-edited fixture wants.
There is no CSV parsing here: a comma inside a line is part of that item. A line that is only whitespace is kept as an empty string when skipping is off, which is what the option says it does.
How to use List to JSON Array
Paste the lines into the List lines box and set Trim each line, Skip blank lines and Read numbers as numbers.
Press Run and read the JSON array below: one element per surviving line, in order.
Set Read numbers as numbers to no when a numeric-looking line is really an identifier such as a phone number.
What to Expect
Best for
- Turning a pasted column into a JSON array
- Keeping an identifier numeric-looking but string-typed
Not ideal for
- CSV, where a comma separates fields
- A list that needs nesting
What this tool keeps
- Line order
- An identifier with leading zeros as a string
What may need cleanup
- Escape a quote by hand if the consumer needs strict JSON5
- A nested structure needs a different tool
Common errors
- The page refuses it: skip blank lines
Example use cases
- Building a fixture from a spreadsheet column
- Turning a list of tags into an array
Sample input
List lines: 1 …
Sample output
JSON array: [ …
Who this is for
- Developers building a test fixture
- Anyone converting a pasted column
Frequently asked questions
Why is a numeric line a string sometimes?
Because you set Read numbers as numbers to no, or because the line is not a plain integer or decimal — a leading zero or a trailing unit keeps it a string.
What does skipping blank lines do?
A blank line is dropped instead of becoming an empty string. With the option off, it is kept as "", which is sometimes exactly what a fixture needs.
Does it split on commas?
No. One line is one item, so a comma inside a line stays inside the item. CSV needs its own parser because quoting changes what a comma means.
Build custom tools for your store
Join the SDK program to create useful ecommerce utilities for your store.