Runs locally in your browser

Convert a List to a JavaScript Array

Create a valid JavaScript string array with safe escaping, configurable quotes, variable name, declaration, and layout.

Input → Result

Turn one item per line into JavaScript array code.

Options
JavaScript array0 items

About this tool

Convert a List to a JavaScript Array

JavaScript arrays appear in fixtures, filters, front-end configuration, and quick scripts. Manual conversion often fails when values contain quotes or backslashes.

Choose a const or let declaration, or output only the array literal. Each line remains a string so leading zeroes and exact text are preserved.

FAQ

Frequently asked questions

Are quotes and backslashes escaped?+

Yes. Double-quoted output uses JSON-compatible escaping, and single-quoted output escapes JavaScript control characters and apostrophes.

Can I get only the brackets and values?+

Yes. Select Array literal only to omit the variable declaration and semicolon.

Related tools

Popular list tools

Browse all tools →

Guides

Related guides

Guides →