For simple array members like that, you can use JSON.parse.

var array = JSON.parse("[" + string + "]");

This gives you an Array of numbers.

[0, 1]

If you use .split(), you'll end up with an Array of strings.

["0", "1"]

Just be aware that JSON.parse will limit you to the supported data types. If you need values like undefined or functions, you'd need to use eval(), or a JavaScript parser.


If you want to use .split(), but you also want an Array of Numbers, you could use Array.prototype.map, though you'd need to shim it for IE8 and lower or just write a traditional loop.

var array = string.split(",").map(Number);
Answer from I Hate Lazy on Stack Overflow
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ javascript โ€บ string-to-array-in-javascript
JavaScript - Convert String to Array - GeeksforGeeks
August 5, 2025 - Modify parts of the string (like replacing characters or extracting substrings). Split a string into smaller components for easier processing. The most common method for converting a string to an array is using the split() method.
๐ŸŒ
Board Infinity
boardinfinity.com โ€บ blog โ€บ string-to-array-conversion-in-javascript
String to Array conversion in JavaScript | Board Infinity
June 13, 2026 - There is just a single method that is quite famous and widely used in JavaScript for turning a String into an array in JS and that is the .split() method. This method divides a string into an array of other strings, using a particular character, ...
Discussions

javascript - Convert string with commas to array - Stack Overflow
In this case alert shows 0,1. If it where an array, it would show 0. And if alert(array[1]) is called, it should pop-up 1 ยท Is there any chance to convert such string into a JavaScript array? More on stackoverflow.com
๐ŸŒ stackoverflow.com
How do you pass a queryset to a JS variable? I want to take a queryset and pass it to js as a simple json array. Can't find any help but surely this is obvious!

Just use a serializer for this, docs here: https://docs.djangoproject.com/en/2.0/topics/serialization/

More on reddit.com
๐ŸŒ r/django
7
0
January 7, 2018
Confused how to convert a string to a byte array. Need to convert equivalent C# snippet in JS

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer

https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding#Appendix.3A_Decode_a_Base64_string_to_Uint8Array_or_ArrayBuffer

More on reddit.com
๐ŸŒ r/javascript
2
1
February 18, 2015
How to Convert an Array to a String in Javascript
๐ŸŒ r/learnjavascript
1
0
April 13, 2021
๐ŸŒ
W3Schools
w3schools.com โ€บ jsref โ€บ jsref_tostring_array.asp
JavaScript Array toString() Method
The toString() method returns a string with array values separated by commas. The toString() method does not change the original array. Every JavaScript object has a toString() method.
๐ŸŒ
Medium
medium.com โ€บ @jsomineni โ€บ 3-ways-to-convert-string-into-array-in-javascript-3eacfc729cf6
3 ways to convert String into Array in JavaScript | by Jayanth babu S | Medium
September 1, 2024 - JavaScript provides several methods to achieve this. In this blog, weโ€™ll explore three of the most popular ways to convert a string into an array: using the split() method, Array.from(), and the spread operator (...).
๐ŸŒ
ReqBin
reqbin.com โ€บ code โ€บ javascript โ€บ jaarxzpl โ€บ javascript-string-to-array-example
How do I convert string to array in JavaScript?
March 9, 2023 - The Array.from() method in JavaScript is used to create an array from any iterable object. The from() method returns a new array instance whose elements correspond to each element in the iterable.
๐ŸŒ
Stack Abuse
stackabuse.com โ€บ how-to-convert-a-string-to-an-array-in-javascript
How to Convert a String to an Array in JavaScript
May 22, 2023 - If you'd like to learn more about Regular Expressions - read our Guide to Regular Expressions and Matching Strings in JavaScript! ... We could split it on each whitespace (breaking it down into words), or on every character, or any other arbitrary delimiter, such as 'p': // Split string using a whitespace let array1 = quote.split(' '); console.log(array1); // ["I", "am", "unstoppable!"] // Splitstring using an empty string (on each character) let array2 = quote.split(''); console.log(array2); // ["I", " ", "a", "m", " ", "u", "n", "s", "t", "o", "p", "p", "a", "b", "l", "e", "!"] // Split string using a specific character let array3 = quote.split('p'); console.log(array3); // ["I am unsto", "", "able!"
Find elsewhere
๐ŸŒ
Altcademy
altcademy.com โ€บ blog โ€บ how-to-convert-string-to-array-in-javascript
How to convert string to array in JavaScript - Altcademy.com
June 9, 2023 - One of the most common ways to convert a string to an array is by using the split() method. The split() method is a built-in JavaScript method that splits a string into an array of substrings based on a specified separator.
๐ŸŒ
DEV Community
dev.to โ€บ kiani0x01 โ€บ convert-string-to-array-in-javascript-o39
Convert String to Array in JavaScript - DEV Community
July 6, 2025 - The simplest way to break a string into parts is using String.prototype.split. Pass a delimiter, and split returns an array of substrings:
๐ŸŒ
CodingNomads
codingnomads.com โ€บ javascript-array-to-string-conversion
JavaScript Array-String Conversion
Next up, you'll be checking out the .split() method, which is like the inverse of .join(). It's used to convert a string to an array. Say you had a string that represented some numbers: ... Perhaps this is what you got from a form input, as ...
๐ŸŒ
Medium
frontendinterviewquestions.medium.com โ€บ how-to-convert-string-to-an-array-in-javascript-c113247bce72
How to convert string to an array in JavaScript ? | by Pravin M | Medium
September 6, 2024 - The split() method is one of the most commonly used ways to convert a string into an array. This method splits a string based on a specified delimiter and returns an array of substrings. let str = "apple,banana,grape,orange"; let arr = ...
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ javascript โ€บ how-to-convert-string-to-array-of-objects-javascript
How to Convert String to Array of Objects JavaScript ? - GeeksforGeeks
August 5, 2025 - If the string is not in JSON format, you can manually split the string and construct objects to create the array, split() method splits the string into an array of individual records based on the semicolon delimiter.
๐ŸŒ
DEV Community
dev.to โ€บ hrishikesh1990 โ€บ how-to-convert-a-string-to-an-array-in-javascript-54g1
How to convert a string to an array in javascript? - DEV Community
June 1, 2021 - Although in this tutorial we focus on the split the other methods that could be used to convert a string to array in JavaScript are Spread, Object.assign, and Array.from.
๐ŸŒ
DEV Community
dev.to โ€บ sanchithasr โ€บ 6-ways-to-convert-a-string-to-an-array-in-javascript-1cjg
6 Ways to Convert a String to an Array in JavaScript - DEV Community
September 24, 2022 - Converting from string to array is always done using the split() method but after ES6, there are many tools we could do the same.
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ article โ€บ converting-string-to-an-array-in-javascript
Converting string to an array in JavaScript
March 15, 2026 - <!DOCTYPE html> <html> <head> <title>Converting string to an array in JavaScript</title> <script> var string = "We are Tutorials point"; const arr1 = string.split(' '); // Split by space const arr2 = string.split(''); // Split into characters const arr3 = string.split(" ", 2); // Split with limit document.write("Words: " + arr1 + "<br>"); document.write("Characters: " + arr2 + "<br>"); document.write("Limited: " + arr3 + "<br>"); // Destructuring assignment let [first, second, third, fourth] = string.split(' '); document.write("Destructured: " + first + ", " + second + ", " + third + ", " + fourth); </script> </head> <body> </body> </html>
๐ŸŒ
airbrake
docs.airbrake.io โ€บ home โ€บ blog โ€บ javascript error handling โ€บ javascript: how to convert a string into an array
JavaScript: How To Convert a String Into an Array - Airbrake Docs
January 19, 2022 - A string stores characters, while an array creates list-like objects due to its ability to hold more than one value. You might need to convert those strings into an array in some cases. The split() method is the most popular way to do this. The split() method is one of the most popular ways ...
๐ŸŒ
Educative
educative.io โ€บ answers โ€บ how-to-convert-a-string-into-an-array-in-javascript
How to convert a string into an array in JavaScript
The split() method can be used to split a string based on the separator provided and return an array of substrings. This method works better if you want to create an array of strings.
๐ŸŒ
YouTube
youtube.com โ€บ tech industry analysis
Converting a String into an array using JavaScript - YouTube
To convert a string into an array use the split() function. This "splits" each character in a string as an indexed item within an array. Moreover, this enabl...
Published: April 14, 2022
Views: 2K
๐ŸŒ
YouTube
youtube.com โ€บ watch
How to Convert String to Array in Javascript - YouTube
In this video, you will learn how to convert string to array in javascript. I hope you'll like the video and leave your feedback and suggestions for future ...
Published: October 24, 2019
๐ŸŒ
C# Corner
c-sharpcorner.com โ€บ home โ€บ technologies โ€บ javascript โ€บ convert string into array in javascript
Convert String into Array in JavaScript
August 21, 2023 - The JavaScript split() method is a powerful method for converting strings to arrays. It divides a string into an array of substrings based on a specified delimiter.