Convert a Key Value Pairs list into a Javascript JSON Array
Convert a spreadsheet list of key values pairs into JavaScript JSON array.
Save time coding and avoid programming errors.
Copy in the text and click Get Results button. JSON array code can be copied out from the bottom textarea.
Use key value pairs like: MyArray[0].key + " " + MyArray[0].value;
Text Inputs
MyArray
key1 value1
key2 value2
key3 value3
Javascript JSON Array Example Code Output
var MyArray = [
{"key":"key1", "value":"value1"},
{"key":"key2", "value":"value2"},
{"key":"key3", "value":"value3"}
];
Ctrl A = Select All, Ctrl C = Copy, Ctrl V = Paste.
Copy the lower Javascript results into a Javascript code editor.
- Convert a list of values into an array
- Create a JSON object, which is the same as an array but more organized and easier to read
- A javascript object in JSON is an associative array with a string key and value.
- It therefore appears very similar to a JavaScript object literal.
- The difference between the two is that the objects are stored as key-value pairs, while literals defines arbitrary keys.
- Javascript objects are nested key-value arrays.