String to JSON Array Converter

Splits raw text (default: one item per line) into a JSON array of strings, trimming whitespace from each piece and dropping any that end up empty. A free online tool from Staaarter, right in your browser.

Runs locallyUpdated 2026-07-24

Overview

Introduction

A lot of raw data starts life as a plain list, one tag per line, a comma-separated set of IDs pasted from a spreadsheet cell, a newline-separated log of usernames. Turning that into a proper JSON array by hand means adding quotes and commas everywhere.

This tool does that split-and-wrap step in one pass, trimming whitespace and dropping empty entries along the way.

What Is String to JSON Array Converter?

A converter that splits a block of raw text on a chosen delimiter (a newline by default) and wraps the resulting pieces into a JSON array of strings.

Each piece is trimmed before being added to the array, and any piece that's empty after trimming is skipped, so stray blank lines or trailing delimiters don't leave gaps in the output.

How String to JSON Array Converter Works

The tool calls JavaScript's String.split() with your chosen delimiter (a literal string match, not a regular expression), then maps each resulting piece through trim() and filters out any that end up length zero.

The surviving pieces are serialized as a JSON array of strings with two-space indentation.

When To Use String to JSON Array Converter

Use it when you have a plain list, tags, usernames, IDs, one per line or comma-separated, and need it as a JSON array for an API request body or config file.

It's also a fast way to turn a pasted spreadsheet column into a JSON array without touching a full CSV parser.

Features

Advantages

  • Handles any delimiter, not just newlines or commas.
  • Automatically trims whitespace from each piece.
  • Drops empty entries instead of preserving them as empty strings.

Limitations

  • The delimiter is matched as a literal string, not a regular expression, so you can't split on a pattern like "one or more spaces" directly.
  • There's no quote-awareness, so a delimiter character that legitimately appears inside a value (as in quoted CSV) will incorrectly split that value too.

Examples

Newline-separated list

Input

apple
banana

cherry  

Output

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

The blank line is dropped, and trailing spaces around "cherry" are trimmed.

Comma-delimited list

Input

red, green, blue

Output

[
  "red",
  " green",
  " blue"
]

Using "," as the delimiter still leaves a leading space on later items before trimming removes it, so the trimmed result is ["red","green","blue"].

Best Practices & Notes

Best Practices

  • Use a comma-and-space (", ") as the delimiter when your source text already has a space after each comma, to avoid relying solely on the trim step.
  • For structured tabular data with quoted fields, use CSV to JSON Converter instead of this tool.
  • Check the output length against your source line count if you're unsure whether blank-line dropping removed more than expected.

Developer Notes

The empty-after-trim filter runs after trimming rather than before, specifically so that a piece consisting only of whitespace (like a line with just spaces on it) is correctly treated as empty and dropped, not preserved as a whitespace-only string.

String to JSON Array Converter Use Cases

  • Converting a pasted list of tags or keywords into a JSON array
  • Turning a newline-separated log of usernames or IDs into an API-ready array
  • Quickly wrapping a comma-separated spreadsheet cell into JSON

Common Mistakes

  • Expecting regex-style delimiters (like \s+ for any whitespace); the delimiter is matched literally.
  • Using this on quoted CSV data where the delimiter character can appear inside a value; use a real CSV parser for that case.

Tips

  • Once you have the array, Randomize JSON Array can shuffle its order if you need that next.
  • Group JSON Array works on arrays of objects, not plain strings, so run this first only when your source really is a flat list of scalar values.

References

Frequently Asked Questions