Skip to content

Instantly share code, notes, and snippets.

@jiayihu
Last active October 31, 2018 21:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jiayihu/abdceeb0f9529a5714a3b91a36fde483 to your computer and use it in GitHub Desktop.
Save jiayihu/abdceeb0f9529a5714a3b91a36fde483 to your computer and use it in GitHub Desktop.
Chrome snippet to console log your localStorage in a pretty format
var items = Object.keys(localStorage);
items.forEach(item => {
try {
const value = JSON.parse(localStorage.getItem(item));
console.group(item);
if (Array.isArray(value)) console.table(value);
else if (Object.prototype.toString.call(value) === '[object Object]') console.table([value]);
else console.log(value);
console.groupEnd(item);
} catch (exception) {
console.warn('Could not JSON parse the item ', item);
console.warn('The error is: ', exception);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment