Text to JavaScript

JavaScript Array Converter

Generate a ready-to-paste JavaScript array from pasted values.

Build the JavaScript array

JavaScript Array Converter

0 items / 0 unique
Input Text
0 characters Ctrl+Enter to convert - Drag and drop .txt
Split Input By
Cleaning Options
Output
Output Format
JavaScript options
Customization
Output 0 unique Output
// Your converted output will appear here.
Equivalent code
Paste text and click Convert Text, or use Ctrl+Enter.
Your text stays private. All conversion happens locally in your browser using JavaScript. Nothing is uploaded to any server.

Choose the declaration keyword, the quote style, and whether numbers and booleans stay quoted strings or become real JavaScript literals.

How It Works

How to use the JavaScript Array Converter

  1. Paste your values

    One per line by default. Switch the delimiter if your source is comma or tab separated.

  2. Set the declaration and quotes

    const, let, var, or none for a bare literal. Double quotes, single quotes, or backticks — backticks additionally escape ${ so template interpolation cannot fire.

  3. Decide how values are typed

    Leave Value type on Strings to quote everything. Switch to Auto when the list really is numbers, booleans or nulls that should be JavaScript literals.

Examples

JavaScript Array Converter examples

A const array of strings

Input

React
Node.js
TypeScript

Output

const technologies = [
  "React",
  "Node.js",
  "TypeScript"
];

Mixed literals with type detection on

Input

42
true
null
hello

Output

const values = [
  42,
  true,
  null,
  "hello"
];

With Value type set to Auto, bare numbers, true/false and null become JavaScript literals rather than strings.

Apostrophes with single quotes selected

Input

O'Brien
D'Angelo

Output

const names = [
  'O\'Brien',
  'D\'Angelo'
];
Notes

Working with text to array javascript

const, let, or a bare literal

const suits a lookup table you never reassign — note that it prevents reassignment of the binding, not mutation of the array, so push() still works. Use let only if you reassign the variable itself. Turn the declaration off when you are pasting into an existing object, a function argument, or a config literal.

Which quote character to pick

Double quotes match JSON and most style guides. Single quotes suit codebases whose linter prefers them. Backticks are worth choosing only when a value already contains both quote types — this tool escapes the backtick and ${ inside them, so a value like ${user} stays literal instead of becoming an interpolation.

Escaping that actually matters

Backslashes, newlines, tabs and the enclosing quote are escaped. So are U+2028 and U+2029, two line separators that are legal inside a JavaScript string but break older parsers and any JSONP-style embedding. You rarely type them; they arrive constantly in text copied from PDFs and word processors.

FAQ

JavaScript Array Converter FAQs

JavaScript Array Converter

Generate a ready-to-paste JavaScript array from pasted values. Choose the declaration keyword, the quote style, and whether numbers and booleans stay quoted strings or become real JavaScript literals.