Design Palette

Client Login


Web Design Files

Dump Method

The Dump method is based on one of the tags available in Coldfusion ( <cfdump>) providing the ability to display simple and complex variables in a user friendly way that is perfect for debugging/inspecting data. There is no way to do this with javascript and often I had wanted a method to do this. This method will do just that allowing for an infinite amount of data nesting complete with color coding for different data types, the ability to show/hide the data's type (String/Number/Boolean/Object/Array/Function), expandable and collapsible tables/keys and cross browser support.

Click on the buttons bellow to see some examples in action, toggle the Show Data Types box to see javascript data typing in action (not possible in Coldfusion).

Thanks to John Wilson for providing the jQuery plugin.

Browser Support

Internet Explorer 6, Internet Explorer 7, Firefox 1.5, Opera 8, Safari 1.2 (Mac), Firefox (Mac) - all tested, should also work in most other browsers

Download

Click here to download the latest version (1.08)
Click here to download the latest jQuery plugin

Dump Examples

Click to see dump examples (Click on headings/keys to expand and collapse tables/values)


Usage

dump(value, [showTypes])
@ param value (Any) value to dump
@ param [showTypes] (Boolean) optional to display each key/value's type
@ return (Void) returns nothing

Examples

dump(myObject, true); // opens a dump window displaying key/value types of myObject
dump([123,456,789], false); // opens a dump window not displaying key/value types of the array passed
dump('string value', false); // opens a dump window showing the string value

Back to Website Files

Click here

Comments

Feel free to comment below.

Submit Comments

All Comments

Will Glaub - 24/01/2013

I love your dump script and am using it for debugging a lot of my work. I have a feature suggestion/request: have a parameter to open the dump with all of the values collapsed initially, so that it's a small list of just the root stuff, which the user can expand, rather than only having the current way backwards of that: having to click to collapse. Thanks.
willglaub@gmail.com

Matthew Boles - 22/06/2012

Anyone know how to alter this so the dump is appended to the html page, instead of in a pop up?
mboles57@gmail.com

yyy - 16/06/2012

uuuu
yyy

re - 10/03/2012

afdadsf
cs

roy - 11/09/2011

its just awesome, i started writing my dump but its lots of effort, i got this. this is just awesome
prashantroy1979@gmail.com

sfsfsf - 04/09/2011

??
??

Gus Denton - 20/05/2011

It's like the heavens heard my prayers today!!!
gd@unsw.edu.au

Won Tok - 19/05/2011

no workee... firefox 4
won.tok@wontok.com

daniel - 17/05/2011

great tool!!! thx. I use it since a longtime. But now, it doesnt' work anymore in firefox 4.

erick Rodriguez - 21/04/2011

seems does not work with firefox 4, please help!!!
tb.erick.rodriguez@gmail.com

D King - 09/12/2010

Thank you for posting this - really useful I use it all the time

ur fucker - 08/12/2010

fuck u dude
hell2fucku@yahoo.com

Matt - 08/04/2010

Thank you Thank you Thank you Thank you Thank you Thank you Thank you Thank you Thank you Thank you Thank you Thank you Thank you Thank you Thank you Thank you Thank you Thank you Thank you Thank you
mlowrey@ucsd.edu

prashant - 11/08/2009

nice, one of the coolest things in js world.

big tool in debugging
prashant_roy8@yahoo.com

cfJquery - 15/05/2009

cf + jquery + dump = dev nirvana

easyQuery - 21/03/2009

good~Thank you!

Frankie BUT - 08/03/2009

i don no ?
doctor620@yahoo.com

bruce - 04/02/2009

Excellent work. Only thing that I see that could be improved would be to limit recursion if an object hierarchy is circular. For myself, I put a hard limit into the code to only go down 10 levels (sufficient for my current needs). But someone with more time on their hands could probably auto detect circular references and make a more general solution.
foo@foo.com

onlinev - 31/01/2009

Hi,

This is max from canada. I am a newbie of this site and i think this site has a lot to provide to the visitors.

onlinev



[/url=http://themastercleanse.org/the-lemonade-diet ]The Lemonade Diet Cleansing Directions[/url]

The Lemonade Diet Cleansing Directions
st.kpo13@gmail.com

deviantz - 10/12/2008

Hello, Very Nice! Thanks!

iczalazar.net

eee - 11/11/2008

eeeee
eee

Small business website design - 23/09/2008

Excellent!

Creative website designer Small business website design We are custom website Designer. Small business web site design, small business website design, small business web designer
webdesignhead@gmail.com

Small business website design - 23/09/2008

thanks
http://www.creativewebsitedesigner.com

Sanjay - 28/08/2008

Excellent!



Thanks
sanjaykanteti@gmail.com

Chandler - 16/07/2008

I saw this function, I peed my pants. Excellent work!

climby - 22/04/2008

I try to dump DOM object such as 'document' etc. But it seems can't work, Does dump support DOM object ?
mdengfeng@gmail.com

Will B. - 07/02/2008

Just FYI, Firefox 2.0.0.11 seems to be opening empty windows. I can only get it to work if I switch to an IE Tab. Maybe it's me...maybe not.



Nice, though!


RatherNot_IfYouPlease@test.com

Jude - 13/12/2007

A few hours after I installed this on my machine and did some work in cfgrid, I got all call from my CIO wanting to know why I hit netgrow.com.au over 2000 times in such a short amount of time. I was wondering the same thing after he brought it to my attention. What's up with that?
jude@nighttimeswerve.com

DJ-Andrey-sXe - 23/11/2007

Very useful & nice. Thank you!

Konstantin Tokar - 17/06/2007

Firefox 2.0.0.4 - don't work any tests.
Konstantin@Tokar.ru

robotacon - 14/05/2007

Excellent!

Ricardo Lopes - 03/05/2007

Awesome, i was looking for something like this for a long time.
rjlopes@gmail.com

Christopher Jordan - 15/03/2007

I think this may go along with the Drill-Down idea that Guillaume posted. If you try and dump something very large, I get memory problems due to too much recursion. What if you didn't automatically expand everything, but rather fetched the data for the particular object the user clicked on *after* they click on it. Does that make sense?
cjordan@placs.net

Christopher Jordan - 15/03/2007

I think this may go along with the Drill-Down idea that Guillaume posted. If you try and dump something very large, I get memory problems due to too much recursion. What if you didn't automatically expand everything, but rather fetched the data for the particular object the user clicked on *after* they click on it. Does that make sense?
cjordan@placs.net

Christopher Jordan - 15/03/2007

Drat! I refreshed... sorry for the double post. :o)
cjordan@placs.net

Shuns - 26/02/2007

There is now a jQuery plugin that can be downloaded aswell. Can be used: jQuery.dump(['a','b'{}], true); or jQuery('input').dump();

Guillaume - 31/01/2007

Idea for improvement : Drill-Down !! :-)

Shuns - 15/01/2007

No licensing restrictions, just a mention is cool :)
shaun@netgrow.com.au

John Hutchison - 03/01/2007

Same question as the first commenter. Any licensing restrictions?
clutterskull@gmail.com

Kroc Camen - 02/01/2007

The code appears unlicensed, do you have any terms you want us to follow if we modify / redistribute? This is very handy code indeed, but I may make a number of modifcations, am I allowed to do so?

Ashish - 27/12/2006

Really handy. Thanks
ashish@apptheory.net

CR Brown - 27/12/2006

This is Amazing ! you should submit this to the various js libs out there, the world would appreciate it ! Thankyou
jsdump@cybrium.net

Christopher Jordan - 23/12/2006

Dude! I've got code that does something similar, but yours blows mine out of the water! Very nice! :o)



I think I'll start using it! :o)
cjordan@placs.net

c ross - 23/12/2006

using coldfsion every day for work, i'm used to using the cfdump feature. You did this for javascript to the 't'. even with expanding and the same colors! Awesome!
cross@intraxinc.com

Mark Holton - 22/12/2006

AWESOME! Thanks!
holtonma@gmail.com

Marc Schipperheyn - 21/12/2006

sweet!
m.schipperheyn@gmail.com

Rey Bango - 21/12/2006

Check out the nice mention over at Ajaxian:



http://ajaxian.com/archives/javascript-variable-dump-in-coldfusion
rey@reybango.com

Steve S. - 12/12/2006

Hallelujah!!!!!
schmism@parknicollet.com

Amir - 04/12/2006

AMAZING!!! Thank you.

Amir - 04/12/2006

One small bug: If value of a variable contains XML or HTML, dump() doesn't show it properly.



REASON: Browser trys to parse the string value which is XML or HTML as soon as it finds "<".



SOLUTION: dump() must convert all instances of "<" to "≤", or at least let the user ask dump to do so.



IDEAL SOLUTION: Values should be prosessed by a function similar to CF's htmlEditFormat()

Guillaume - 01/12/2006

Really magic!

Got a small problem (I am no Javascript expert !) with variables whose type 'unknown' (??) lead to errors.

-> quickly solved by handling this special case in the code

Marcos Placona - 01/12/2006

That's really magic!!! Will save me hours of debuging.



Marcos Placona

http://placona.co.uk
marcos.placona@gmail.com

Jim - 29/11/2006

That is so useful!

Good work

SHUNS - 28/11/2006

COOL

Bill - 28/11/2006

Good Job!

Guillaume - 28/11/2006

This is absolutely wicked !!

David - 16/11/2006

Very nice. Could use a Label argument too - useful for showing which variable is being dumped. And (as opposed to CF) just have it in the outermost box's header?
davidl@teratech.com

Nick - 14/11/2006

Sweet. I have been looking for this for years.

Jason - 11/11/2006

Totally Awesome!!

Kurt Bonnet - 11/11/2006

You rock!! This is fantastic.



In every language (other than CF) that I work with, I think to myself, I wish I had a CFDUMP equivelant. I'm sure this will save me plent of time debugging my JS.



This would be a great thing to put on Google Code Projects.

Binny V A - 11/11/2006

Great job.



I had created a dump function for javascript. My version was inspired by the print_r() function of PHP instead of Cold Fusion.

It is available here...

Dump() Function for Javascript



My function is much simpler that your function.

Mark - 10/11/2006

SWEET!

Pim - 10/11/2006

It's the same as the one in coldfusion but very handy for JS .. thks
pim.man@gmail.com

shuns - 11/10/2006

Very handy.