Let's say I have copied a JSON-style string like this:

 [['a', 'what\'s up'], ['c', 'd']]

into the clipboard (for example copied from my browser Dev Console, after some JS code).

How can I easily paste this into a Google Sheet, directly into cells (split by columns / rows)?

1 Answer 1


Create a new script:

 * Evaluates JS code.
 * @param {code} code The code to evaluate.
 * @return The result from evaluating the code.
 * @customfunction
function RUNJS(code) {
  return eval(code); 

than paste your JS into cell A2 (for example) and put this formula in A3:


the result will be:


  • 1
    Where do you create this script, and how to link it with this particular spreadsheet? Also, if RUNJS just does eval, isn't it possible to just execute eval in Google Sheets directly?
    – Basj
    May 6 at 15:52
  • paste the script into: Extensions-->Apps Script -->Files ( add a file )--> Script This script will work only in the sheet where it was created. There is no Eval () function in google sheet but if you prefer you could name this EVAL.
    – Daniele
    May 6 at 16:09
  • 1
    Would JSON.parse() be safer than eval()?
    – TRiG
    May 6 at 16:15
  • I don't know... but JSON do not use single quotations mark... you could try ... no danger
    – Daniele
    May 6 at 16:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.