Search code examples
javascriptbrowserwebkit

How do I get the webkit console to just log without UI parsing?


In both Firefox and Chrome variants, logging a nested object produces a folded view with UI controls for viewing it; to see this, throw something like console.log({foo: 'bar', baz: {bat: 'squanch'}}) into either one.

Sometimes I'd like to retrieve some data from a running app and work on it in an editor, but this is really grinding my gears.

How do I get the webkit console to spit out some raw text output of an object's contents that I can copy and paste somewhere else?


Solution

  • console.log(JSON.stringify(stuff));
    

    However, note that it will only work correctly with primitive types, and if the structure is not circular. If it is, you will have to drill down to pick out things you can JSONify.