A PlainSift practical guide

Convert a text list to a JSON array without broken escaping

Create a valid array of strings, including values with quotes, backslashes, and leading zeros.

Adding quotes and commas by hand works only until a value contains a quote or a backslash. A JSON serializer handles those characters consistently. PlainSift takes one item per line and uses JSON.stringify to create an array of strings that can be parsed as JSON.

This is useful for test fixtures, configuration lists, and identifiers copied from another tool. Every value stays a string: “0012” keeps its leading zeros, and “true” does not become a boolean. Check that the consumer actually expects an array of strings rather than numbers, objects, or a comma-delimited field.

Start with Lines to a JSON array

Free, no sign-up. Your pasted text stays in the browser workspace.

Step-by-step instructions

These steps use the default options shown in each tool. Add changes in the order listed.

  1. Lines to a JSON array

    Open Lines to a JSON array, paste one item per line, and keep pretty output enabled. Select Run pipeline, review the escaped strings, then copy the result.

Review the full output, then use Copy result or Download .txt.

Before and after

Input

0012
Say "hello"
C:\Reports\draft

Result

[
  "0012",
  "Say \"hello\"",
  "C:\\Reports\\draft"
]

The identifier remains a string. Quotes and backslashes are escaped in the JSON document; parsing it restores the original characters.

Clean before encoding, only when needed

The converter does not trim values, remove duplicates, or discard blank lines. A blank line inside a list becomes an empty string item, and surrounding spaces become part of the corresponding string. That is deliberate: encoding should not silently change the source data.

If blank lines are accidental, start with Remove empty lines and add Lines to a JSON array as the last step. Add Trim lines before those steps only if edge spaces should also disappear. Do not apply line-cleaning steps after conversion: the new lines belong to the JSON layout, not to the original item boundaries.

Pretty and minified JSON contain the same values

Pretty output uses two-space indentation to make a review easier. Minified output removes the formatting whitespace between JSON tokens. Neither choice removes spaces inside string values. Select the form your configuration file, test runner, or request editor expects.

A final line terminator in the original text does not create an extra empty array item. An actual interior blank line does. A single item containing an embedded line break cannot be represented unambiguously in one-item-per-line input; author that value in JSON or another structured format instead.

Common questions

Can I convert the JSON array back to plain text?

Use JSON array to lines for a top-level array containing only strings. Embedded escaped newlines become real line breaks, so an item containing a newline will occupy more than one output line.

Does this create a JavaScript expression?

The result is JSON text. It contains no variable assignment, comments, trailing commas, or executable code. The reverse tool uses JSON.parse and rejects non-string array items.