Ready, runs in your browser
0 chars · 0 words
bytes leaving your device
0
every item, always
Strings
no signup, no run limit
Free

Space to JSON array

What the space to JSON array converter does

You paste a list with spaces between the items and get back a JSON array you can drop straight into a config file, a test fixture or a request body. Each item is trimmed, empties are dropped, and the result is pretty-printed with two-space indentation.

The useful part is what counts as a separator. Any run of whitespace does: one space, five spaces, a tab, a line break, or a mixture of all of them. So a list you copied out of a terminal or a wrapped email converts on the first try instead of needing a tidy-up first.

Everything happens in your browser. Nothing is uploaded, there is no cap on how many items a list can hold and no account step in the way.

Workflow

How to convert a space separated list to JSON in three steps

The third step is the one people skip, and it is the one that catches the real mistakes.

Step 1
Paste the list exactly as you copied it. Messy spacing is fine, and so are line breaks in the middle of it.
Step 2
Run the conversion. It is instant, and it happens on your own machine.
Step 3
Count the items in the output against what you pasted. A higher count means one of your values contained a space and got split in two.

Know this before you paste

Every item is a string, and that is on purpose

The array is always an array of strings. 42 comes back as "42", true comes back as "true", and nothing is inferred from the look of a value.

That is a deliberate trade. Converters that guess types are the ones that turn a product code like 0042 into the number 42 and lose the leading zeros permanently, or turn 1e5 into 100000. Casting two values yourself afterwards is a small job. Finding the ones that were silently rewritten is not.

What it handles cleanly

The messy input this converter copes with

Four things that break a naive split, handled here without any options to set.

Uneven spacing
Double and triple spaces collapse into one separator instead of producing empty items.
Mixed separators
Tabs, spaces and line breaks in the same list all act as the same boundary.
Leading and trailing space
Each item is trimmed, and whitespace at either end of the whole list is ignored.
Quotes and backslashes
Escaped properly, so the array stays valid JSON and parses.
Accents and CJK text
Passed through exactly as pasted, with no transliteration or stripping.

Pick the right route

When a space separated list is the wrong shape

If your items contain spaces of their own, full names, film titles, addresses, this route will split each one into several items. That is correct behaviour for a space delimiter and completely wrong for your data.

Use the route that matches your real separator instead. Comma, semicolon, colon, pipe, slash, tab, caret, tilde and double space each have a page, and there is a custom delimiter route for anything else. If your list is one item per line, the line-based routes are a better fit than this one.

Limits, stated

What this converter will not do for you

It makes a flat array of strings. That is the whole feature, and the things it does not do are worth knowing before you plan around them.

No dedupe
Repeats stay, in order. The remove duplicate lines route handles that job.
No empty strings
Empty items are always filtered out, so you cannot deliberately produce one.
No compact mode
Output is always indented. Run it through the JSON minifier if you need one line.
No objects or nesting
Multi-column data belongs in a CSV converter, not here.
No file upload, batch or API
One pasted list at a time, in the browser.

Where this fits

Where the converter fits in your workflow

It sits between an informal list and code. Someone sends you eight feature flags in a chat message, or you copy a set of IDs out of a log, and the array you need is thirty seconds away rather than a manual quoting exercise with a high chance of one missing comma.

It is also worth running before you hand a list to anything that will act on it, because the item count is a free validation step. Eight things pasted and nine items back means one of them is not what you think it is.

Who it's for

Who converts a space separated list to JSON, and when

Three recurring situations.

Developers writing config
Turning a handful of flags, hosts or IDs into an array for a settings file or an environment variable.
Anyone writing test data
Producing a fixture array from a list someone pasted into a ticket or a chat thread.
API work
Building a request body by hand and needing a list of values as valid JSON without hand-quoting each one.
FAQ

Everything answered. Questions about converting lists to JSON arrays

How do I turn a space separated list into a JSON array?

Paste the list into the box above and run it. Each whitespace-separated item becomes one string in the array.

Is this converter free?

Yes. No account, no item cap and no run limit, because it runs on your own device.

Is my list uploaded?

No. The conversion happens entirely in your browser and nothing is transmitted or logged.

What happens if my list has double spaces?

They are treated as one separator, so you do not get empty items in the middle of the array.

Can the list span several lines?

Yes. Line breaks are whitespace, so they act as separators just like spaces do.

Are numbers turned into JSON numbers?

No. Every item is a string, so 42 becomes "42" and nothing is reinterpreted.

Why does it not detect types?

Because inference damages values like 0042 and 1e5. Keeping strings means what you pasted is what you get.

Is the output valid JSON?

Yes. Quotes and backslashes inside items are escaped, so the array parses as-is.

Does it keep accented or Chinese characters?

Yes, exactly as pasted. Nothing is transliterated or removed.

Does it remove duplicate items?

No. Duplicates are kept in order. Use the remove duplicate lines route for that.

Can I keep empty items?

No. Empty entries are always dropped by this route.

Can I get the array on a single line?

Not from this page. It always pretty-prints, and the JSON minifier compacts it in one more step.

My names got split in half. Why?

Because each name contains a space, and space is the separator here. Use a comma or custom delimiter route instead.

Which delimiter routes exist?

Comma, semicolon, colon, pipe, slash, tab, caret, tilde, double space, and a custom delimiter route.

How long can my list be?

There is no limit, since nothing is being sent to a server to be processed.

Can I upload a text file?

No. It works on text you paste into the page.

Is there an API?

Not currently. This is a browser tool for one list at a time.

Does it work on phones?

Yes, the same as on desktop.

Can it produce an array of objects?

No. The output is always a flat array of strings.

Why is my item count higher than expected?

A value containing a space was split into two items. That count mismatch is the point of checking it.

Is it safe for confidential data?

Yes. Nothing leaves your browser, so there is nothing to transmit or retain.

Can I convert a list of file paths with spaces in them?

Not on this route. Paths containing spaces need a delimiter that is not whitespace, such as the comma or custom delimiter routes.