Whatever message this page gives is out now! Go check it out!

cfdump

Last update:
May 18, 2026

Description

Use the cfdump tag to get the elements, variables, and values of most kinds of ColdFusion objects. Useful for debugging. You can display the contents of simple and complex variables, objects, components, user-defined functions, and other elements. The cfdump now shows component properties defined by cfproperty when you dump a CFC. A new key called PROPERTIES has been added in the component dump, which is expanded, by default. The text format of cfdump also provides this information.

Category

Syntax

<cfdump 
var = "#variable#" 
output = "browser|console|file" 
format = "text|html" 
abort = "true|false"> 
label = "text" 
metainfo = "yes|no" 
top = "number of rows|number of levels" 
show = "columns|keys" 
hide = "columns|keys" 
keys = "number of keys to display for structures" 
expand = "yes|no" 
showUDFs = "yes|no">
Note: You can specify this tag's attributes in an attributeCollection attribute whose value is a structure. Specify the structure name in the attributeCollection attribute and use the tag's attribute names as structure keys.

See also

History

  • ColdFusion (2025 release): Displays additional details in the output, such as, methods in a Java class, constructors, which lists all the constructors for the class showing the method and the declared exceptions that can be thrown, Methods inherited from <parent object>, and the list of methods includes the exceptions that can be thrown. See the examples for more imformation.
  • ColdFusion 9: Added the attribute abort.
  • ColdFusion 8: Added the show, format, hide, keys, metainfo, output, and showUDFs attributes.
  • ColdFusion MX 7: Added the top attribute.
  • ColdFusion MX 6.1: Added the ability to dump COM objects; it displays the methods and Get and Put properties typeinfo information for the object.

Attributes

Attribute
Req/Opt
Default
Description
var
Required
Variable to display. Enclose a variable name in number signs. These kinds of variables yield meaningful cfdump output:
  • array
  • CFC
  • COM object
  • file object
  • Java object
  • simple
  • query
  • structure
  • UDF
  • wddx
  • xml
expand
Optional
yes
  • yes: expands views.
  • no: contracts expanded views.
format
Optional
text
Use with the output attribute to specify whether to save the results of a cfdump to a file in text or HTML format.
hide
Optional
all
For a query, this is a column name or a comma-delimited list of column names. For a structure, this is a key or a comma-delimited list of keys.

If you specify a structure element that doesn't exist, ColdFusion ignores it and does not generate an error.
keys
Optional
9999
For a structure, the number of keys to display.
label
Optional
A string; header for the dump output. Ignored if the value of the var attribute is a simple types.
metainfo
Optional
yes for query{{no}} for persistence CFCs
For use with queries and persistence CFCs. Includes information about the query in the cfdump results, including whether the query was cached, the execution time, and the SQL. Specify metainfo="no" to exclude this information from the query result. For persistence CFCs, if metainfo="yes", returns property attributes such as getters and setters.
output
Optional
browser
Where to send the results of cfdump. The following values are valid:
  • browser
  • console
  • filename The filename must include the full pathname of the file. You can specify an absolute path, or a path that is relative to the ColdFusion temporary directory. You can use the GetTempDirectory() function to determine the ColdFusion temporary directory.
show
Optional
all
For a query, this is a column name or a comma-delimited list of column names. For a structure, this is a key or a comma-delimited list of keys.
showUDFs
Optional
yes
  • yes: includes UDFs, with the methods collapsed.
  • no: excludes UDFs.
top
Optional
9999
The number of rows to display. For a structure, this is the number of nested levels to display.
abort
Optional
false
If this attribute is set to "true", it stops processing the current page at the tag location.

Usage

The expand/contract display capability is useful when working with large structures, such as XML document objects, structures, and arrays.
To display a construct, use code such as the following, in which myDoc is a variable of type XmlDocument:
<cfif IsXmlDoc(mydoc) is "yes"> 
 <cfdump var="#mydoc#"> 
 </cfif>
The tag output is color-coded according to data type.

If a table cell is empty, this tag displays "empty string".

Example

<!--- This example shows how to use this tag to display the CGI scope as a structure: ---> 

<cfdump var="#cgi#"><!--- This displays information about file objects. ---> 
<cfscript> 
myfile = FileOpen("c:\temp\test1.txt", "read"); 
</cfscript> 
myfile refers to: 
<cfdump var="#myfile.filepath#">
Examples
<!--- class name --->
<cfset boolVal = true>
<cfdump var ="#boolVal.getClass()#">
code
<cfset obj = createObject("java", "java.io.File")>
<cfdump var="#obj#" >
code
<cfscript>
    nestedArr = [[1, 2, 3], ["a", "b", "c"], [true, false]];
    writedump(var="#nestedArr.getClass()#");
</cfscript>
The script creates a nested array and dumps its Java class details using getClass(). The updated cfdump now shows additional details like methods, constructors, inherited methods, and exceptions.

Real-world uses of the cfdump tag

Debugging API responses

Your e-commerce company integrates with a payment gateway API to process customer transactions. Recently, some payments have been failing, but the error messages are unclear. You need to inspect the complete API response to understand what data is being returned and identify the issue.
Problem statement
  • Payment processing occasionally fails without clear error messages
  • Need to see the full structure of API responses
  • Must identify which fields are missing or malformed
  • Time-sensitive issue affecting customer checkout experience
Use cfdump to display the complete API response structure, including all nested objects, arrays, and properties. This allows you to:
  • See exactly what data the API is returning
  • Identify missing or unexpected fields
  • Understand the structure of error responses
  • Compare successful vs. failed responses
<cfscript>
    // Simulate calling a payment gateway API
    function processPayment(amount, cardNumber) {
        // In real scenario, this would be an actual API call
        // Example: result = httpService.post(paymentGatewayURL, paymentData);
        
        var apiResponse = {
            "status": "error",
            "transaction_id": "TXN-" & createUUID(),
            "amount": amount,
            "currency": "USD",
            "timestamp": now(),
            "error": {
                "code": "INVALID_CARD",
                "message": "Card number validation failed",
                "details": {
                    "field": "card_number",
                    "reason": "Invalid checksum"
                }
            },
            "metadata": {
                "processor": "StripeGateway",
                "api_version": "2023.1",
                "request_id": "req_" & randRange(10000, 99999)
            }
        };
        
        return apiResponse;
    }
    
    // Process a payment
    paymentResult = processPayment(99.99, "4111111111111111");
</cfscript>

<h2>Payment API Response Debugger</h2>

<!--- Use cfdump to display the complete API response structure --->
<cfdump 
    var="#paymentResult#" 
    label="Payment Gateway API Response"
    expand="yes">

<!--- For production environments, output to a log file instead --->
<cfif isDefined("url.debug") AND url.debug EQ "logfile">
    <cfdump 
        var="#paymentResult#" 
        output="#getTempDirectory()#payment-debug.html"
        format="html"
        label="Payment Debug Log - #dateFormat(now(), 'yyyy-mm-dd')# #timeFormat(now(), 'HH:mm:ss')#">
    <p>Debug information saved to: #getTempDirectory()#payment-debug.html</p>
</cfif>

<!--- Display specific error information if present --->
<cfif structKeyExists(paymentResult, "error")>
    <h3>Error Details:</h3>
    <cfdump 
        var="#paymentResult.error#" 
        label="Error Object"
        expand="yes">
</cfif>

Database query inspection

Your customer support application runs a complex SQL query to retrieve customer order history. The query joins multiple tables and includes calculated fields. Team members report that some customers see incomplete data, and query performance seems slow.
Problem statement
  • Complex queries with multiple joins and calculations
  • Inconsistent results for certain customers
  • Need to verify what data is actually being returned
  • Must check query execution time and metadata
  • SQL logic needs validation before optimization
Solution
Use cfdump with the metainfo attribute to display both the query results and execution details.
<cfscript>
    // Simulate a complex customer order query
    // In real scenario, this would query your actual database
    customerOrderQuery = queryNew(
        "orderID,customerName,orderDate,productName,quantity,unitPrice,totalAmount,status",
        "integer,varchar,date,varchar,integer,decimal,decimal,varchar"
    );
    
    queryAddRow(customerOrderQuery, [
        {
            orderID: 1001,
            customerName: "John Smith",
            orderDate: dateAdd("d", -5, now()),
            productName: "Laptop Computer",
            quantity: 1,
            unitPrice: 1299.99,
            totalAmount: 1299.99,
            status: "Shipped"
        },
        {
            orderID: 1002,
            customerName: "John Smith",
            orderDate: dateAdd("d", -3, now()),
            productName: "Wireless Mouse",
            quantity: 2,
            unitPrice: 29.99,
            totalAmount: 59.98,
            status: "Delivered"
        },
        {
            orderID: 1003,
            customerName: "John Smith",
            orderDate: now(),
            productName: "USB Cable",
            quantity: 3,
            unitPrice: 9.99,
            totalAmount: 29.97,
            status: "Processing"
        }
    ]);
</cfscript>

<h2>Customer Order History - Debug View</h2>

<!--- Display complete query with metadata --->
<cfdump 
    var="#customerOrderQuery#" 
    label="Customer Order Query Results"
    metainfo="yes"
    expand="yes">

<hr>

<!--- Show only specific columns --->
<h3>Simplified View (Selected Columns Only)</h3>
<cfdump 
    var="#customerOrderQuery#" 
    label="Order Summary"
    show="orderID,orderDate,productName,totalAmount,status"
    top="10">

<hr>

<!--- Hide sensitive columns --->
<h3>Customer Service View (Sensitive Data Hidden)</h3>
<cfdump 
    var="#customerOrderQuery#" 
    label="Orders (Public View)"
    hide="unitPrice,customerName">

<!--- Output to console for server-side debugging --->
<cfif isDefined("url.debug") AND url.debug EQ "console">
    <cfdump 
        var="#customerOrderQuery#" 
        output="console"
        label="Query Console Debug">
    <p>Query data sent to console (check ColdFusion logs)</p>
</cfif>

<!--- Display query statistics --->
<cfscript>
    queryStats = {
        "totalRecords": customerOrderQuery.recordCount,
        "totalOrderValue": dollarFormat(arraySum(customerOrderQuery["totalAmount"])),
        "averageOrderValue": dollarFormat(arrayAvg(customerOrderQuery["totalAmount"])),
        "columnList": customerOrderQuery.columnList
    };
</cfscript>

<h3>Query Statistics</h3>
<cfdump var="#queryStats#" label="Summary Stats">

Session data debugging

Your web application uses session variables to track user authentication, preferences, shopping cart contents, and navigation history. Users are reporting that they're being logged out unexpectedly, and shopping cart items are disappearing. You need to inspect the session scope to understand what's happening.
Problem statement
  • Users experiencing unexpected logouts
  • Session data seems to be lost or corrupted
  • Shopping cart losing items between pages
  • Need to verify session structure and contents
  • Must track session state across requests
  • Difficult to see nested session objects
Solution
Use cfdump to display the entire session scope or specific session variables.
<cfscript>
    // Initialize session data (simulating a real user session)
    session.user = {
        "userID": 12345,
        "username": "jsmith@example.com",
        "firstName": "John",
        "lastName": "Smith",
        "role": "customer",
        "loginTime": now(),
        "lastActivity": now(),
        "isAuthenticated": true,
        "preferences": {
            "theme": "dark",
            "language": "en",
            "notifications": true,
            "currency": "USD"
        }
    };
    
    session.shoppingCart = {
        "cartID": "CART-" & createUUID(),
        "items": [
            {
                "productID": 501,
                "name": "Wireless Keyboard",
                "quantity": 1,
                "price": 79.99
            },
            {
                "productID": 502,
                "name": "Monitor Stand",
                "quantity": 2,
                "price": 45.00
            }
        ],
        "subtotal": 169.99,
        "tax": 13.60,
        "total": 183.59,
        "createdAt": dateAdd("h", -2, now()),
        "lastUpdated": now()
    };
    
    session.navigation = {
        "currentPage": getCurrentTemplatePath(),
        "previousPage": "/products/index.cfm",
        "pageHistory": ["home", "products", "cart"],
        "visitCount": 5
    };
</cfscript>

<!--- Security check: Only show in development mode --->
<cfif isDefined("application.environment") AND application.environment EQ "development">
    
    <h2>Session Data Inspector</h2>
    <p><strong>Environment:</strong> Development Mode</p>
    <p><strong>Session ID:</strong> #session.sessionID#</p>
    
    <!--- Display entire session scope --->
    <cfdump 
        var="#session#" 
        label="Complete Session Scope"
        expand="no"
        top="5">
    
    <hr>
    
    <!--- Display user information only --->
    <h3>User Session Data</h3>
    <cfdump 
        var="#session.user#" 
        label="User Information"
        expand="yes">
    
    <hr>
    
    <!--- Display shopping cart with sensitive data hidden --->
    <h3>Shopping Cart Contents</h3>
    <cfdump 
        var="#session.shoppingCart#" 
        label="Cart Debug"
        expand="yes"
        hide="cartID">
    
    <hr>
    
    <!--- Show only specific user fields --->
    <h3>Authentication Status</h3>
    <cfdump 
        var="#session.user#" 
        label="Auth Info"
        show="userID,isAuthenticated,loginTime,lastActivity">
    
    <!--- Log session data to file for persistent debugging --->
    <cfif isDefined("url.logSession")>
        <cfset debugFileName = "session-debug-" & session.user.userID & "-" & dateFormat(now(), "yyyymmdd-HHMMSS") & ".html">
        <cfdump 
            var="#session#" 
            output="#getTempDirectory()##debugFileName#"
            format="html"
            label="Session Debug Log - User #session.user.userID#">
        <p style="color: green;">Session data logged to: #getTempDirectory()##debugFileName#</p>
    </cfif>

<cfelse>
    
    <!--- Production environment - don't expose session data --->
    <h2>Session Debugging Disabled</h2>
    <p>Session debugging is only available in development environments for security reasons.</p>
    
</cfif>

<!--- Display session statistics without sensitive data --->
<cfscript>
    sessionInfo = {
        "sessionExists": structKeyExists(session, "user"),
        "isLoggedIn": structKeyExists(session, "user") AND session.user.isAuthenticated,
        "cartItemCount": structKeyExists(session, "shoppingCart") ? arrayLen(session.shoppingCart.items) : 0,
        "sessionAge": structKeyExists(session, "user") ? dateDiff("n", session.user.loginTime, now()) & " minutes" : "N/A"
    };
</cfscript>

<h3>Session Summary (Safe for all environments)</h3>
<cfdump var="#sessionInfo#" label="Session Stats">

File upload validation and debugging

Your company's document management system allows users to upload various file types (PDFs, images, Word documents). Recently, users have reported upload failures and file corruption. Some uploads succeed but the files aren't accessible. You need to debug the file upload process and validate that files are being processed correctly.
Problem statement
  • File uploads failing without clear error messages
  • Need to verify file metadata and properties
  • Must validate file size, type, and content
  • Unclear what data is captured during upload
  • File object structure is not well understood
  • Need to log upload details for troubleshooting
Solution
Use cfdump to inspect file upload objects and cffile operation results.
<!--- Create a simple upload form --->
<cfif NOT isDefined("form.fileUpload")>
    <h2>File Upload Debugger</h2>
    <p>Upload a file to see detailed information about the upload process.</p>
    
    <form method="post" enctype="multipart/form-data">
        <div style="margin: 20px 0;">
            <label for="fileUpload">Select a file to upload:</label><br>
            <input type="file" name="fileUpload" id="fileUpload" required>
        </div>
        <div>
            <button type="submit">Upload and Analyze</button>
        </div>
    </form>
    
    <!--- Show request information for debugging upload issues --->
    <h3>Current Request Information</h3>
    <cfscript>
        requestInfo = {
            "templatePath": getCurrentTemplatePath(),
            "requestMethod": isDefined("form") ? "POST" : "GET",
            "formSubmitted": structKeyExists(form, "fileUpload")
        };
    </cfscript>
    <cfdump 
        var="#requestInfo#" 
        label="Request Information"
        expand="yes">

<cfelse>
    
    <!--- File was uploaded, process and analyze it --->
    <h2>File Upload Analysis</h2>
    
    <cfscript>
        // Define upload directory (use temp directory for demo)
        uploadDir = getTempDirectory() & "uploads/";
        
        // Create directory if it doesn't exist
        if (!directoryExists(uploadDir)) {
            directoryCreate(uploadDir);
        }
    </cfscript>
    
    <!--- Perform the file upload --->
    <cftry>
        <cffile 
            action="upload" 
            fileField="fileUpload" 
            destination="#uploadDir#" 
            nameConflict="makeunique"
            result="uploadResult">
        
        <h3>✓ Upload Successful</h3>
        
        <!--- Display complete upload result --->
        <cfdump 
            var="#uploadResult#" 
            label="File Upload Result Object"
            expand="yes">
        
        <hr>
        
        <!--- Get additional file information --->
        <cfscript>
            uploadedFilePath = uploadResult.serverDirectory & "/" & uploadResult.serverFile;
            fileInfo = getFileInfo(uploadedFilePath);
        </cfscript>
        
        <!--- Display detailed file information --->
        <h3>Extended File Information</h3>
        <cfdump 
            var="#fileInfo#" 
            label="File System Details"
            expand="yes">
        
        <hr>
        
        <!--- Create a summary object with key information --->
        <cfscript>
            uploadSummary = {
                "originalFileName": uploadResult.clientFile,
                "serverFileName": uploadResult.serverFile,
                "fileSize": numberFormat(uploadResult.fileSize) & " bytes (" & numberFormat(uploadResult.fileSize / 1024, "0.00") & " KB)",
                "mimeType": uploadResult.contentType & "/" & uploadResult.contentSubType,
                "fileExtension": uploadResult.serverFileExt,
                "uploadStatus": uploadResult.fileWasSaved ? "Saved Successfully" : "Upload Failed",
                "serverPath": uploadResult.serverDirectory,
                "uploadedAt": now(),
                "fileExists": fileExists(uploadedFilePath)
            };
        </cfscript>
        
        <h3>Upload Summary (User-Friendly View)</h3>
        <cfdump 
            var="#uploadSummary#" 
            label="Quick Summary"
            expand="yes">
        
        <hr>
        
        <!--- Display only the most important fields --->
        <h3>Key Upload Details</h3>
        <cfdump 
            var="#uploadResult#" 
            label="Essential Info"
            show="clientFile,serverFile,fileSize,contentType,fileWasSaved"
            expand="yes">
        
        <!--- Log upload details to file --->
        <cfif isDefined("url.logUpload")>
            <cfset logFileName = "upload-log-" & dateFormat(now(), "yyyymmdd-HHMMSS") & ".html">
            <cfdump 
                var="#uploadResult#" 
                output="#getTempDirectory()##logFileName#"
                format="html"
                label="File Upload Log - #uploadResult.clientFile#">
            <p style="color: green;">Upload details logged to: #getTempDirectory()##logFileName#</p>
        </cfif>
        
        <!--- Validation example --->
        <cfscript>
            validationResults = {
                "isValidSize": uploadResult.fileSize <= 5000000, // 5MB limit
                "isValidType": listFindNoCase("jpg,jpeg,png,gif,pdf,doc,docx", uploadResult.serverFileExt),
                "fileWasSaved": uploadResult.fileWasSaved,
                "securityCheck": uploadResult.fileSize > 0
            };
            
            allValid = true;
            for (key in validationResults) {
                if (!validationResults[key]) {
                    allValid = false;
                    break;
                }
            }
        </cfscript>
        
        <h3>Validation Results</h3>
        <cfdump 
            var="#validationResults#" 
            label="File Validation"
            expand="yes">
        
        <cfif allValid>
            <p style="color: green; font-weight: bold;">✓ All validation checks passed!</p>
        <cfelse>
            <p style="color: red; font-weight: bold;">✗ Some validation checks failed!</p>
        </cfif>
        
        <p><a href="?">Upload Another File</a></p>
        
        <cfcatch type="any">
            <!--- Display error information --->
            <h3 style="color: red;">✗ Upload Failed</h3>
            
            <cfdump 
                var="#cfcatch#" 
                label="Error Details"
                expand="yes"
                show="message,detail,type,tagContext">
            
            <p><a href="?">Try Again</a></p>
        </cfcatch>
    </cftry>
    
</cfif>

<!--- Display form data if available (useful for multi-part forms) --->
<cfif structKeyExists(form, "fileUpload") AND structCount(form) GT 1>
    <h3>Additional Form Data</h3>
    <cfdump 
        var="#form#" 
        label="Form Scope"
        hide="fileUpload"
        expand="yes">
</cfif>

Share this page

Was this page helpful?
We're glad. Tell us how this page helped.
We're sorry. Can you tell us what didn't work for you?
Thank you for your feedback. Your response will help improve this page.

On this page