Every variable stores some kind of data. That data might be a person's name, a number, a date, a list of products, or even an entire object.
The type of data stored in a variable is called its data type.
Understanding data types is important because different types of data support different operations. For example, you can add two numbers together, but adding two dates doesn't make sense in the same way. Similarly, you can convert text to uppercase, but you can't convert a number to uppercase.
One of the great features of ColdFusion is that it is dynamically typed. You don't have to declare a variable's data type before assigning a value. ColdFusion automatically determines the appropriate type based on the value you assign.
By the end of this lesson, you'll understand the most common ColdFusion data types and know when to use each one.
Learning Objectives
After completing this lesson, you'll be able to:
- Understand what a data type is.
- Identify the common ColdFusion data types, including null.
- Store different types of values in variables, in both CFScript and Tag Syntax.
- Check a variable's data type with isNumeric(), isBoolean(), isDate(), and isValid().
- Know when to use each data type.
What Is a Data Type?
A data type tells ColdFusion what kind of value a variable contains. For example:
| Value | Type |
|---|---|
| "John" | String |
| 25 | Number |
| 99.95 | Decimal Number |
| true | Boolean |
| now() | Date & Time |
Dynamic Typing
Unlike Java or C#, you don't specify a variable's type. Simply assign a value.
<cfscript>
name = "Sandeep";
age = 28;
salary = 55000.75;
isAdmin = true;
</cfscript>ColdFusion automatically determines each variable's data type.
One more thing worth knowing: internally, ColdFusion treats every value as an object under the hood, running on the JVM. As a beginner you don't need to think about that — just assign a value the normal way, and ColdFusion handles the rest.
Common ColdFusion Data Types
| Data Type | Description | Example |
|---|---|---|
| String | Text | "Hello" |
| Numeric | Whole or Decimal Number | 100, 25.5 |
| Boolean | true or false | true |
| Date/Time | Date and Time value | now() |
| Array | Ordered list of values | ["A","B"] |
| Struct | Key-value collection | {name="John"} |
| Query | Database result set | <cfquery> |
| Component (Object) | Instance of a CFC | new User() |
| Binary | File/Image/PDF data | Uploaded file |
| Null (Adobe CF 2021+) | No value assigned | javaCast("null","") |
String
A String stores text.
Numeric
Numeric values include whole numbers, decimal numbers, and negative numbers. Numbers support mathematical operations.
Boolean
A Boolean represents one of two values, true or false, and is commonly used in conditions.
Date & Time
ColdFusion has excellent built-in support for dates.
<cfscript>
today = now();
writeOutput(today);
</cfscript><cfset today = now()>
<cfoutput>
#today#
</cfoutput>Example output: 31-Jul-2026 10:15 PM — the exact value changes every time you run it, since now() returns the current date and time. Later in the course, you'll learn date formatting and calculations.
Array
An Array stores multiple values in order.
Arrays will be covered in detail in the Collections module.
Structure (Struct)
A Struct stores data as key-value pairs, similar to a JSON object or a dictionary in other languages.
Query
A Query stores the rows and columns returned by a database call — the result of running a <cfquery> tag or calling queryExecute(). A query can contain multiple rows and columns, and you can loop over it just like an array of records.
<cfscript>
employees = queryExecute(
"SELECT firstName, lastName FROM Employees"
);
</cfscript>You'll learn queries in detail in the Database module.
Component (Object)
A Component is created from a .cfc file. Objects contain properties and methods.
<cfscript>
user = new User();
</cfscript>You'll study Components in the OOP module.
Binary
Binary data represents files instead of readable text — images, PDFs, ZIP files, videos.
You'll rarely create binary data by hand — it usually comes from reading a file from disk or accepting a file someone uploaded.
Null (Adobe ColdFusion 2021+)
Modern Adobe ColdFusion supports a real null value, meaning "no value assigned," distinct from an empty string or a zero. Older ColdFusion versions didn't have true null support — an undefined variable simply threw an error instead.
<cfscript>
value = javaCast("null", "");
</cfscript>You won't need this often as a beginner, but it's worth recognizing when you see it in modern codebases.
Checking the Data Type
ColdFusion provides several isXxx() functions to check a variable's type — the ones you'll reach for most often are isNumeric(), isBoolean(), and isDate(), plus the more general-purpose isValid().
Using isNumeric()
Using isBoolean()
Using isDate()
Using isValid()
isValid() is more generic than the others — it can check many different kinds of values, not just numbers, booleans, and dates, using a type name you pass in as a string (like "email", "numeric", "date", and several more).
Dumping Variables
During development, writeDump() (CFScript) and <cfdump> (tags) help you inspect a variable's type and contents.
<cfscript>
employee = {
name = "John",
age = 30
};
writeDump(employee);
</cfscript><cfset employee = {
name = "John",
age = 30
}>
<cfdump var="#employee#">writeDump() and <cfdump> display the same information — writeDump() is simply the CFScript equivalent of the <cfdump> tag.
Real-World Example
This example demonstrates multiple data types working together. The writeDump() output isn't shown here since it renders as a structured HTML table rather than plain text.
Visual Overview
1. Storing Numbers as Text
age = "25";
Although ColdFusion can often convert it automatically, it's better to store numbers as numbers:
age = 25;
2. Using Quotes with Boolean Values
isAdmin = "true";
isAdmin = true;
3. Confusing Arrays and Structs
colors = ["Red","Green","Blue"];
colors = {
primary = "Red"
};4. Assuming Variable Types Never Change
Because ColdFusion is dynamically typed, the same variable can store different data types:
value = 10; value = "Ten"; value = true;
While this is allowed, avoid changing a variable's type unnecessarily — it makes code harder to read.
Best Practices
- Store numbers as numbers.
- Store Boolean values as true or false.
- Use Arrays for ordered collections.
- Use Structs for related key-value data.
- Use meaningful variable names.
- Use isNumeric(), isBoolean(), isDate(), or isValid() to check untrusted input before using it.
- Use writeDump() or <cfdump> while learning to inspect variables.
Quick Revision
| If you want to store... | Use |
|---|---|
| Name or Text | String |
| Age or Price | Numeric |
| Yes / No | Boolean |
| Current Date | Date & Time |
| Multiple Ordered Values | Array |
| Key-Value Data | Struct |
| Database Records | Query |
| Object | Component (CFC) |
| File or Image | Binary |
| No Value Assigned | Null |
Interview Questions
What is a data type?
A data type defines the kind of value stored in a variable.
Is ColdFusion statically or dynamically typed?
ColdFusion is dynamically typed.
Can one application use multiple data types?
Yes.
Which data type stores multiple ordered values?
Array.
Which data type stores key-value pairs?
Struct.
Which function is useful for inspecting variables during development?
writeDump() (or <cfdump> in tag syntax).
Which functions check for a specific type, besides isValid()?
isNumeric(), isBoolean(), and isDate().
What data type did Adobe ColdFusion 2021 add real support for?
Null.
Summary
In this lesson, you learned what data types are and why they are important. You saw that ColdFusion automatically determines a variable's type based on the assigned value, making the language easy for beginners while remaining powerful for large applications.
You also learned the most commonly used data types — String, Numeric, Boolean, Date & Time, Array, Struct, Query, Component (Object), Binary, and Null — along with how to inspect variables using writeDump() and validate data using functions like isNumeric(), isBoolean(), isDate(), and isValid().
A solid understanding of data types is the foundation for writing reliable ColdFusion applications, because almost every program stores, processes, and displays different kinds of data.
What's Next?
The next lesson covers Comments — why they matter, single-line and multi-line comments, HTML comments vs. ColdFusion comments, and how to comment code in both CFScript and Tag Syntax.