To parse it you need to use double quotes instead of single.

This should work:

services = '["service1", "service2", "service3"]'
JSON.parse(services)
Answer from Erick R Soto 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.
Discussions

Convert string into an array of arrays in javascript - Stack Overflow
You can use the eval() function to convert your string to an array. More on stackoverflow.com
๐ŸŒ stackoverflow.com
javascript - how to convert an array string to an array - Stack Overflow
Communities for your favorite technologies. Explore all Collectives ยท Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work More on stackoverflow.com
๐ŸŒ stackoverflow.com
September 29, 2021
JavaScript - Converting string-array to an array of strings - Stack Overflow
However, I would like to convert this string, into a formal array of strings. ... I get object. I have tried JSON.parse() and JSON.stringify but to no luck. The basics of my question are how do I (in JavaScript) convert a string array, into an array of strings? More on stackoverflow.com
๐ŸŒ stackoverflow.com
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
๐ŸŒ
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 ...
๐ŸŒ
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 - The from() method from the Array class is the leading contender to the split() method. It's used to create an array, given a source of data - and naturally, it can be used to create an array from an iterable string:
๐ŸŒ
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.
๐ŸŒ
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.
๐ŸŒ
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.
Find elsewhere
๐ŸŒ
Delft Stack
delftstack.com โ€บ home โ€บ howto โ€บ javascript โ€บ convert string to array javascript
How to Convert String Into Array in JavaScript | Delft Stack
February 2, 2024 - For example, create a variable num and store a value 1234 as a string in the variable. Call the from() method with an object Array and supply the num variable as the parameter in the function. Store the expression in a variable arr.
๐ŸŒ
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.
Top answer
1 of 3
5

The first thing you should try and do is to make my_string a valid JSON string. That means that instead of single quotes (') you have double quotes (") around your strings. To create a JSON string like this, you can use JSON.stringify() on the data you want to be converted into a string. Below is a valid JSON string of your array which you can use JSON.parse(my_string) on:

const my_string = '[["page1",5],["page2",3],["page3",8]]';
const res = JSON.parse(my_string);
console.log(res);

If you can't do this for whatever reason, then you can try one of the below options.

You can use JSON.parse() and .replace() to make your string a valid JSON string that is parseable like so:

const my_string = "['page1',5],['page2',3],['page3',8]",
stringified = '['+my_string.replace(/'/g, '"')+']';

console.log(JSON.parse(stringified));

Or you can use a Function constructor to "loosly" parse your JSON. Note that you should only use this if my_string is coming from a trusted source (ie: not user input):

const  my_string  = "['page1',5],['page2',3],['page3',8]";
arr = Function('return [' +  my_string + ']')(); 

console.log(arr);

2 of 3
1

You can use the eval() function to convert your string to an array. See the code below.

my_string = "['page1',5],['page2',3],['page3',8]";

my_array = eval(`[${my_string}]`);

console.log(my_array);

However, using the eval() function comes with a set of drawbacks if not used properly. Please read through this answer before using eval in any of your serious code.

๐ŸŒ
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 - In JavaScript, you can create an array using square brackets ([]). Here's an example: ... In this example, myArray is an array containing five elements: the numbers 1, 2, 3, 4, and 5. There are many reasons why you might want to convert a string ...
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ article โ€บ converting-string-to-an-array-in-javascript
Converting string to an array in JavaScript
March 15, 2026 - The Array.from() method creates a new array from any iterable object, including strings. It's particularly useful for converting strings into character arrays.
๐ŸŒ
Attacomsian
attacomsian.com โ€บ blog โ€บ javascript-convert-string-to-array
How to convert a string to an array in JavaScript
August 12, 2022 - The String.split() method converts a string into an array of substrings using a separator and returns a new array. It splits the string every time it matches against the given separator.
๐ŸŒ
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.
๐ŸŒ
YouTube
youtube.com โ€บ watch
javascript : convert string array to array - YouTube
how to convert string array to array in javascript.
Published: November 1, 2015
๐ŸŒ
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