🔤

Text List to Array Converter

Paste a plain list —one item per line —and get it as a JavaScript, Python, PHP, Ruby, or JSON array instantly. Choose single or double quotes and copy the result.

Text Tools Runs locally No data sent
arraylistconvertbrowser only
Text List (one item per line)
JavaScript Array

What is Text List to Array?

Text List to Array converts a plain text list —one item per line —into an array literal in the programming language of your choice. It supports JavaScript, Python, PHP, Ruby, and JSON, with options for quote style and whitespace handling.

How to Use Text List to Array

  1. Paste your list (one item per line) into the input area.
  2. Select the target language: JavaScript, Python, PHP, Ruby, or JSON.
  3. Choose single or double quotes.
  4. Toggle 'Trim whitespace' and 'Skip empty lines' as needed.
  5. Click Copy to copy the array literal.
Understand Array Conversion ▾
Example
Input apple banana cherry
Output ["apple", "banana", "cherry"] (JavaScript, double quotes)
Common Use Cases
  • Convert a list of product names into a JavaScript array for a front-end component
  • Turn a copied list of IDs into a Python list literal
  • Build a JSON array from a plain text item list
  • Quickly scaffold test data arrays from a spreadsheet column
Why Use This Tool
  • Saves time when scaffolding arrays from copied lists or spreadsheet data.
  • Handles quote escaping automatically so you don't need to do it manually.
  • Supports five languages with a single click to switch between them.
  • Runs locally —no text is sent to any server.
Frequently Asked Questions
Which languages are supported?

JavaScript, Python, PHP, Ruby, and JSON. The array syntax differs slightly between languages —for example Python and JavaScript use the same bracket syntax but PHP and Ruby differ.

Can I choose single or double quotes?

Yes. Use the Quote dropdown to switch between single and double quotes. JSON always uses double quotes regardless of the setting.

What happens to empty lines?

By default empty lines are skipped. Uncheck 'Skip empty lines' to include them as empty string items.

Does it handle special characters?

Yes. Quotes and backslashes inside items are automatically escaped for the selected language.