An in-browser JavaScript variable dumper, similar in functionality to ColdFusion's cfdump tag.

Overview

prettyPrint.js

© James Padolsey

prettyPrint.js is an in-browser JavaScript variable dumper, similar in functionality to ColdFusion's cfdump tag.

First, a preview:

Preview:

prettyPrint.js preview

Features:

  • Entirely independent. It requires NO StyleSheets or images.
  • Handles infinitely nested objects.
  • All native JavaScript types are supported plus DOM nodes/elements!
  • Protects against circular/repeated references.
  • Allows you to specify the depth to which the object will be printed.
  • Better browser users benefit from gradient column-headers! Thanks to HTML5 and CANVAS!
  • Allows low-level CSS customisation (if such a thing exists).

Usage:

Download prettyPrint.js and include it in your document:

<script src="prettyPrint.js"></script>

Whenever you want to pretty-print an object of any type simple call prettyPrint:

prettyPrint( myObject );

That, on its own, won't do anything though; prettyPrint returns a table which you can handle in any way you desire. For example, if you wanted to insert the table at the very top of the document:

var tbl = prettyPrint( myObject );
document.body.insertBefore( tbl, document.body.firstChild );

Or, appending it to the document:

document.body.appendChild(tbl);

Configuration:

Custom settings can be passed (as an object) as the second argument to the prettyPrint() function:

prettyPrint(myFoo, {
	// Config
	maxArray: 20, // Set max for array display (default: infinity)
	expanded: false, // Expanded view (boolean) (default: true),
	maxDepth: 5 // Max member depth (when displaying objects) (default: 3)
})

tip: Scroll to line ~679 of prettyprint.js for more configuration options.

Comments
  • maxArray default value was not checked

    maxArray default value was not checked

    maxArray is documented with an "infinite" default value, but the default value '-1' was not checked so the default behavior was actually to always compact arrays if maxArray was not overridden.

    opened by KevinGaudin 1
  • Setting to limit array length

    Setting to limit array length

    Adding a setting "maxArray" that allows one to limit the display length of large arrays. Useful for scenejs/webgl objects that have tens of thousands of geometry points.

    opened by btdrucke 1
  • bower component support

    bower component support

    Add Bower (http://twitter.github.com/bower/) Support

    Bower is a web component registry developed by twitter. Kinda like ruby gems or node npm modules. Its adopted by many javascript dev/frameworks/etc.

    To register it should just be:

    bower register prettyPrint git://github.com/padolsey/prettyPrint.js.git
    
    opened by halkeye 0
  • /** License */ &  Spaces

    /** License */ & Spaces

    I noticed in prettyprint.js, the license at the top was not commented in the typical "don't minify me out!" style. ( /** at the top, as opposed to /* ) I've added this in, as well as did a quick removal of rogue spaces.

    opened by stephenplusplus 0
  • prettyprint.js w/ BSD license.

    prettyprint.js w/ BSD license.

    Per email from James Padolsey that I received on 2011/04/30 at 5:33AM, prettyprint.js is licensed under the 2 clause BSD license.

    Thanks for the email about the license, here's a version of prettyprint.js with the license included.

    Eric Haszlakiewicz

    opened by hawicz 0
  • Preview link in readme does 404

    Preview link in readme does 404

    https://camo.githubusercontent.com/ed43da36bdd4d8d25ee1f75f6b2d65a333f44cb0/687474703a2f2f696d673133322e696d616765736861636b2e75732f696d673133322f353839302f7072657474797072696e74707265766965772e706e67

    opened by tuxayo 0
  • expanding tables

    expanding tables

    This is a really cool project. I like how you can expand tables and reach new depths. In some tables I have too much text to display. Can there be a way to expand a table so that it can display all of the text?

    opened by d3netxer 0
  • very nice, but when running from XUL need namespace

    very nice, but when running from XUL need namespace

    this thing is super. it should be updated to use gradient rather than data urls for the gradients.

    however for firefox, i dump objects to a new tab. i used this, but it was creating the table and the tr would not be a new row. it would be a huge table in one line. i finally figured out the problem.

    it was creating a XUL element.

    so createElement needs to updated to: createElementNS('http://www.w3.org/1999/xhtml', type);

    opened by Noitidart 0
Owner
Padolsey (Archived Projects)
Just a place for old stuff :)
Padolsey (Archived Projects)
Make the content slide prettily across the screen with variable sizes of scrolling items, in any of four directions, pausing while the mouse is over the marquee, and all with vanilla JavaScript.

TEG Marquee Make the content slide prettily across the screen with variable sizes of scrolling items, in any of four directions, pausing while the mou

Paul B. Joiner 0 Dec 30, 2021
Minifies css variable names

PostCSS Variable Compress postcss-variable-compress is a PostCSS plugin minifies variable names and saves space. Even if you have 1295 css variables s

null 20 Nov 19, 2022
Self-hosted environment variable management platform

envplat - environment platform This project is under development. Please contact me for any information or collaboration. Self-hosted environment vari

Environment Platform 4 Apr 25, 2022
This is a simple javascript file that gives you control over the browser cursor, alowing for fully animated cursors using CSS's cursor functionality.

animatedWebCursors.js This is a simple javascript file that gives you control over the browser cursor, alowing for fully animated cursors using CSS's

alienmelon 32 Dec 25, 2022
Zero Dependency, Vanilla JavaScript Tag Editor

_____ |_ _|___ ___ ___ ___ ___ | | | .'| . | . | -_| _| |_| |__,|_ |_ |___|_| |___|___| version 0.4.4 Tagger: Zero dependenc

Jakub T. Jankiewicz 155 Nov 25, 2022
Colr Pickr, a vanilla JavaScript color picker component built with SVGs, with features like saving colors. Similar design to the chrome-dev-tools color picker.

Colr Pickr Colr Pickr, a vanilla JavaScript color picking component built with SVGs, with features like saving colors. Similar design to the chrome-de

TEK 27 Jun 27, 2022
Custom alert box using javaScript and css. This plugin will provide the functionality to customize the default JavaScript alert box.

customAlertBoxPlugin Custom Alert Box Plugin Using JavaScript and CSS Author: Suraj Aswal Must Include CSS Code/Default Custom Alert Box Class: /* mus

Suraj Aswal 17 Sep 10, 2022
VanillaSelectBox - A dropdown menu with lots of features that takes a select tag and transforms it into a single or multi-select menu with 1 or 2 levels

vanillaSelectBox v1.0.0 vanillaSelectBox : v1.00 : Adding a package.json file New : Possibility to change the dropdown tree and change the remote sear

philippe MEYER 103 Dec 16, 2022
Felipe Santana's Figma Course Tag Generator

Gerador de Tags do Curso de Figma do Felipe Santana Deployment After having run the create-remix command and selected "Vercel" as a deployment target,

Jardel Gonçalves 6 Apr 27, 2022
A multi-tag input for sanity studio.

sanity-plugin-tags A multi-tag input for sanity studio. Fully featured with autocomplete capabilities, live updates, predefined tag options, style and

P Christopher Bowers 7 Jul 22, 2022
A logseq plugin to extract tweets. Optionally tag the tweet's author as well.

Logseq Twitter Extractor Plugin If this plugin helps you, I'd really appreciate your support. You can buy me a coffee here. A quick utility to parse a

null 17 Nov 17, 2022
Simple tag input for Bootstrap

Tagin Simple tag input for Bootstrap. Supports bootstrap v4 and v5. Demo: https://tagin.netlify.app/ Features Custom separators Enable/disable duplica

Erwin Heldy G 37 Sep 28, 2022
Tag cloud plugin for jQuery, showing bigger tags in the center

jquery.tagcloud v1.2.0 Tag cloud plugin for jQuery, showing bigger tags in the center. Usage There are two ways to define a tag cloud: Use ul and li H

Peter Thoeny 1 Jun 30, 2022
Generate release notes from git commit history either commit range or tag range.

Would you like to support me? Release Notes Generate release notes from git commit history either commit range or tag range. App Store Template Change

Numan 6 Oct 8, 2022
🏏 GitHub action to split your Git release tag into SemVer 2.0 parts

?? Git Tag Action GitHub action to split your Git release tag into SemVer 2.0 parts This is a simple action to split your git tag, usually for release

Noel 5 Oct 31, 2022
A compilation of Google Tag Manager (GTM) adapters written for measuring interactions with embedded content.

Google Tag Manager (GTM) Custom HTML Adapters for Measuring Embedded Content Interactions This repository contains adapters for sending interaction da

Derek Cavaliero 7 Oct 3, 2022
Tag semantically with one command.

gsvt Create git semver tags with additional major and minor tags easily Example Let's say the latest tag is v2.1.1: Command Result gsvt v2.1.2, v2.1,

ViPro (京京) 3 Sep 24, 2022
Tampermonkey script which adds the ability to add a user-defined label/tag/flair on a user, shown throughout Hacker News.

Hacker News User Tags Hacker News User Tags is a Tampermonkey userscript which allows the user to associate a custom coloured label/tag on usernames t

Lachlan McDonald 2 Oct 7, 2022
It's an AI Tag (Prompt) generator for magic drawer! We have many tags and support to generate prompts easily!

魔导绪论 AI 魔咒生成器, 使用由 B 站 UP 主 十二今天也很可爱 提供的 4 万个 tag 并提供中文检索,并提供了魔咒社区方便魔法师们直接复制生成。永远免费,永无广告,无商业。 v2 版本更新内容 使用 Netlify 的云函数提供更为快速的社区数据操作!(暂时不知道花费多少) 查看自己的

江夏尧 28 Jan 1, 2023