Nekonote Toolbox logo

Nekonote Toolbox

Free browser-based tools for developers and IT admins.

日本語

Text Lines to Array Code

About this tool

Paste a list with one item per line, choose a language, and get a ready-to-paste array or list definition. It saves you from adding quotes and commas by hand when you turn a column of values, a list of names or a set of test inputs into code.

Everything runs in your browser. What you paste is never sent to a server.

Example

Input:
apple
orange
it's

PHP output:
array(
  'apple',
  'orange',
  'it\'s'
)

Python output:
[
  'apple',
  'orange',
  'it\'s'
]

How it works

  • Empty lines are removed, and leading and trailing spaces on each line are trimmed. The order is kept.
  • PHP, Python, Ruby and JavaScript use single-quoted strings. Java uses double quotes in a List<String> list = Arrays.asList(...) declaration.
  • Quotes and backslashes are escaped, so a Windows path such as C:\temp\ can be pasted as is.
  • Every item is written as a string, including numbers. If you need numbers, remove the quotes from the output.
  • Only line breaks separate items. For comma- or tab-separated tables, use CSV/TSV to Array Code.

FAQ

Q. How many lines can I convert?

A. The conversion runs in your browser, so a few thousand lines is fine. There is no server-side limit because nothing is uploaded.

Q. Is the text I paste stored or sent anywhere?

A. No. It stays in your browser tab.