Skip to Content

How to Dump Data with the CFDump Tag in CFML

In this tutorial, you'll learn how to use the cfdump tag, a CFML tag used to output the contents of a variable of any data type into a user-friendly and legible format.

Advertising Disclosure: I am compensated for purchases made through affiliate links. Click here for details.

The Attributes

  • var string - The name of the variable to display, enclosed in pound signs.
  • expand boolean - Expand or collapse key/value pairs within the output. The default value is true, or expanded. false collapses all key/value pairs, allowing them to expand with a click. 
  • label string - A header for the dump table output.
  • top numeric - For queries and arrays, this is the number of rows to display. For structures, this is the number of nested levels to display. Supported in CF7+.
  • format string - Allows you to save the dump results to a file in HTML or text format. Available values are html and text. Supported in CF8+.
  • metainfo boolean - Includes the query details in the result output. Supported in CF8+.
  • output string - Where to output the dump results. Available values are browser, console, and filename. Supported in CF8+.
  • keys numeric - The number of keys to display in a structure. Supported in CF8+.
  • hide string - Hide column or key/value pairs. Supported in CF8+.
  • show string - Show column or key/value pairs. Supported in CF8+.
  • showUDFs boolean - Show UDFs in dump output. Supported in CF8+.
  • abort boolean - Stops processing of a page. Supported in CF9+.

Code Examples

The following code snippets output the server scope with a table caption of "Server Scope".

Tag Syntax

<cfdump var="#server#" label="Server Scope">

Script Syntax

writeDump(var = server, label = "Server Scope");

Lucee Script Syntax

dump(var = server, label = "Server Scope");

Dump Then Abort Page Processing

<cfdump var="#server#" abort>

Conclusion

Here, you learned how to use the cfdump tag and all its attributes, including how to abort page processing for cases where you need to look at a quick data output.

Posted by: Josh Rowe
Created: August 29, 2023

Comments

There are no comments yet. Start the conversation!

Add A Comment

Comment Etiquette: Wrap code in a <code> and </code>. Please keep comments on-topic, do not post spam, keep the conversation constructive, and be nice to each other.