Convert a Text list into a Javascript Array

Convert a list of values into JavaScript array.
Copy in the text and click Get Results button. Array code can be copied out from the bottom textarea.

Text Inputs


array item 1
array item 2
array item 3

Javascript Array Code Output

var MyArray = ['array item 1','array item 2','array item 3'];

JavaScript Array Name

Your text list to copy in here

Use Notepad or a text editor to open your text list file and copy the contents into the top text area box. You can also type in your list manually.
Shortcuts include: Ctrl A for select all, Ctrl C for copy and Ctrl V for paste.

       Press Get Result button after completing copying in list in to text area above.

JavaScript Array Results Here

Copy the lower Javascript results into a Javascript code editor.

What is a JavaScript Array

JavaScript arrays are a runtime representation of lists, or sequences in JavaScript. They can be created and manipulated using either arrays or array functions.

How to convert a text list into an array in JavaScript

Array length can be defined by a numeric variable that has zero initialized (e.g. var arrLength = 0;). Creating an array is simple, and it starts with the keyword new. The form of the new quote marks determines what type of data you need to store there in order to add it into your list (e.g., "new Array();" would create an empty array with no items).

  • How do you convert a text list into an array in Javascript
  • Tools to use for converting text lists into arrays
  • Example of converting a list into an array in JavaScript
  • How to convert a text list into an array