Convert PHP array to JS Object

Input data

This form allows you convert PHP Array to Javascript literal object, you only need to insert the array syntax [...] or array(...), paste or upload your array below:


Your result can be seen below.

Result of PHP Array conversion to JS object


Move to "Paste Code" for Save it

About PHP Array conversion to Javascript object

About PHP Array conversion to JS Object

The Convert PHP array to Javascript object was created for online converting PHP array into JavaScript object. This can be useful for programmers who need to transfer some logic from the php programming language to javascript. You do not need to download any tools for conversion.

How it Works?

Just paste your PHP array to the textarea above and click to the button "Convert" and you will get javascript object in the next textarea.

Example of PHP Array conversion to Javascript object

Before:
[
  'first_section' => [
    'one' => '1',
    'test' => 'sample',
    'animal' => 'BIRD',
  ],
  'second_section' => [
    'path' => '/var/test',
    'URL' => 'https://wtools.io/',
    'second_section' => [
      'one' => '1 associated',
      'two' => '2 associated',
      0 => '1 unassociated',
      1 => '2 unassociated',
    ],
  ],
  'third_section' => [
    'version' => ['7.0','7.1','7.2','7.3'],
  ],
]
After:
{
	first_section: {
		one: "1",
		test: "sample",
		animal: "BIRD"
	},
	second_section: {
		path: "/var/test",
		URL: "https://wtools.io/",
		second_section: {
			0: "1 unassociated",
			1: "2 unassociated",
			one: "1 associated",
			two: "2 associated"
		}
	},
	third_section: {
		version: [
			"7.0",
			"7.1",
			"7.2",
			"7.3"
		]
	}
}
After the conversion, you can apply the JS object to your project or use it for some other purpose.