Null vs. Empty — What's the Difference?
By Tayyaba Rehman — Updated on September 22, 2023
Null indicates the absence of value or the absence of a reference, often representing an undefined or uninitialized state. Empty, on the other hand, refers to an object or variable that is initialized but contains no elements, values, or meaningful data.
Difference Between Null and Empty
Table of Contents
ADVERTISEMENT
Key Differences
Null is a term frequently used in programming to indicate the absence of a value or the absence of a reference. It represents an undefined state or an uninitialized variable. In databases, a null value indicates that a particular field has no value or is undefined. Empty, conversely, is used to denote that a given object, string, or data structure has been initialized but contains no elements or meaningful data. In databases, an empty field would be one that has been initialized but contains no information.
When you encounter the term "null," it usually means that the variable or object in question has not been assigned any value or object. It's a placeholder for "nothing" or "unknown." Empty, however, means that the variable or object has been assigned a value, but that value has no length or elements. For instance, an empty array has been initialized but has zero elements.
Null and empty serve different purposes and are often not interchangeable. For example, in programming languages like JavaScript, a variable can be null, but it cannot be null and empty at the same time. Checking for null and empty conditions often requires separate conditional statements. In SQL databases, a null value in a field means the absence of data, while an empty string might be used to indicate that the data is known to be blank.
In practical use, null is often used for object references or pointers that should not point to any location in memory. It's like saying, "This pointer points to nowhere." On the other hand, empty is like saying, "This container exists, but it's currently holding nothing." While both concepts are related to the absence of data, null usually indicates a more fundamental lack of definition than empty.
Comparison Chart
Definition
Absence of value
Initialized but no data
ADVERTISEMENT
State
Undefined/Uninitialized
Defined/Initialized
In Databases
Field has no value
Field is blank but initialized
Programming Use
Placeholder for 'nothing'
Indicates zero length
Data Type
Often used for object references
Often used for collections
Compare with Definitions
Null
Null indicates the absence of value.
The variable is null because it hasn't been assigned a value yet.
Empty
Empty means a variable or object is initialized but contains no data.
The array is empty because it has zero elements.
Null
Null represents an undefined state.
The function returned null, which means it didn't work as expected.
Empty
Empty signifies a lack of elements in a data structure.
An empty string is a string with zero characters.
Null
Null is often used for uninitialized variables.
If a variable is null, it means it hasn't been set up yet.
Empty
Empty is used to describe containers that hold nothing.
The list is empty and needs to be populated.
Null
Null is common in databases to indicate missing data.
In the database, a null value signifies that the information is not available.
Empty
Containing nothing; not filled or occupied
The room was empty of furniture
She put down her empty cup
Null
Null is a placeholder for "nothing" or "unknown."
The API returned null for the fields it could not populate.
Empty
(of words or a gesture) lacking meaning or sincerity
Their promises were empty words
Null
Having no legal force; invalid
Render a contract null and void.
Empty
Having no value or purpose
Her life felt empty and meaningless
Null
Of no consequence, effect, or value; insignificant.
Empty
Remove all the contents of (a container)
Pockets were emptied of loose change
We empty the till at closing time
Null
Amounting to nothing; absent or nonexistent
A null result.
Empty
A bottle or glass left empty of its contents
The barman collected the empties
Null
(Mathematics) Of or relating to a set having no members or to zero magnitude.
Empty
Having nothing inside or on the surface; holding or containing nothing
An empty bag.
An empty lot.
Null
To make null.
Empty
(Mathematics) Having no elements or members; null
An empty set.
Null
Zero; nothing.
Empty
Having no occupants; not being used
An empty chair.
Null
An instrument reading of zero.
Empty
Not having an incumbent or occupant; unfilled
An empty post at the embassy.
Null
A non-existent or empty value or set of values.
Empty
Not put to purposeful use; idle
Empty hours.
Null
Zero quantity of expressions; nothing.
Empty
Lacking force or power
An empty threat.
Null
Something that has no force or meaning.
Empty
Lacking purpose or substance; meaningless
An empty life.
Null
(computing) The null character; the ASCII or Unicode character (␀), represented by a zero value, which indicates no character and is sometimes used as a string terminator.
Empty
Needing nourishment; hungry
"More fierce and more inexorable far / Than empty tigers or the roaring sea" (Shakespeare).
Null
(computing) The attribute of an entity that has no valid value.
Since no date of birth was entered for the patient, his age is null.
Empty
Devoid; destitute
Empty of pity.
Null
One of the beads in nulled work.
Empty
To remove the contents of
Emptied the dishwasher.
Null
(statistics) The null hypothesis.
Empty
To transfer or pour off completely
Empty the ashes into a pail.
Null
Having no validity; "null and void".
Empty
To unburden; relieve
Empty oneself of doubt.
Null
Insignificant.
Empty
To become empty
The theater emptied after the performance.
Null
Absent or non-existent.
Empty
To discharge its contents
The river empties into a bay.
Null
(mathematics) Of the null set.
Empty
An empty container.
Null
(mathematics) Of or comprising a value of precisely zero.
Empty
Devoid of content; containing nothing or nobody; vacant.
An empty purse
An empty jug
An empty stomach
Null
Causing a complete loss of gene function; amorphic.
Empty
Containing no elements (as of a string, array, or set), opposed to being null (having no valid value).
Null
Neutral.
Empty
(obsolete) Free; clear; devoid; often with of.
Null
To nullify; to annul.
Empty
Having nothing to carry, emptyhanded; unburdened.
Null
To return to the null position, setting, etc.
Empty
Destitute of effect, sincerity, or sense; said of language.
Empty words, or threats
Empty offer
Empty promises
Null
To form nulls, or into nulls, as in a lathe.
Empty
Unable to satisfy; hollow; vain.
Empty pleasures
Null
To crack; to remove restrictions or limitations in (software).
Empty
Destitute of reality, or real existence; unsubstantial.
Empty dreams
Null
Of no legal or binding force or validity; of no efficacy; invalid; void; nugatory; useless.
Faultily faultless, icily regular, splendidly null,Dead perfection; no more.
Empty
Destitute of, or lacking, sense, knowledge, or courtesy.
Empty brains
An empty coxcomb
Null
Having a value of zero; as, of null utility.
Empty
(of some female animals, especially cows and sheep) Not pregnant; not producing offspring when expected to do so during the breeding season.
Empty cow rates have increased in recent years.
Null
Empty; having no members; as, the null set.
Empty
Producing nothing; unfruitful.
An empty vine
Null
Unassigned or meaningless; - a special value given to variables, especially pointers or logical variables, indicating that it is meaningless and cannot be used in computation; as, an uninitialized pointer in "C" is given a null value. The actual value that is stored in memory to indicate the null condition may vary with the computer language used.
Empty
To make empty; to void; to remove the contents of.
To empty a well or a cistern
The cinema emptied quickly after the end of the film.
Null
Something that has no force or meaning.
Empty
(intransitive) Of a river, duct, etc: to drain or flow toward an ultimate destination.
Salmon River empties on the W shore about 2 miles below Bear River.
Null
That which has no value; a cipher; zero.
Empty
A container, especially a bottle, whose contents have been used up, leaving it empty.
Put the empties out to be recycled.
Null
One of the beads in nulled work.
Empty
Containing nothing; not holding or having anything within; void of contents or appropriate contents; not filled; - said of an inclosure, or a container, as a box, room, house, etc.; as, an empty chest, room, purse, or pitcher; an empty stomach; empty shackles.
Null
To annul.
Empty
Free; clear; devoid; - often with of.
I shall find you empty of that fault.
Null
A quantity of no importance;
It looked like nothing I had ever seen before
Reduced to nil all the work we had done
We racked up a pathetic goose egg
It was all for naught
I didn't hear zilch about it
Empty
Having nothing to carry; unburdened.
When ye go ye shall not go empty.
Null
Lacking any legal or binding force;
Null and void
Empty
Destitute of effect, sincerity, or sense; - said of language; as, empty words, or threats.
Words are but empty thanks.
Empty
Unable to satisfy; unsatisfactory; hollow; vain; - said of pleasure, the world, etc.
Pleas'd in the silent shade with empty praise.
Empty
Producing nothing; unfruitful; - said of a plant or tree; as, an empty vine.
Seven empty ears blasted with the east wind.
Empty
Destitute of, or lacking, sense, knowledge, or courtesy; as, empty brains; an empty coxcomb.
That in civility thou seem'st so empty.
Empty
Destitute of reality, or real existence; unsubstantial; as, empty dreams.
Empty
An empty box, crate, cask, etc.; - used in commerce, esp. in transportation of freight; as, "special rates for empties."
Empty
To deprive of the contents; to exhaust; to make void or destitute; to make vacant; to pour out; to discharge; as, to empty a vessel; to empty a well or a cistern.
The clouds . . . empty themselves upon the earth.
Empty
To discharge itself; as, a river empties into the ocean.
Empty
To become empty.
Empty
A container that has been emptied;
Return all empties to the store
Empty
Make void or empty of contents;
Empty the box
The alarm emptied the building
Empty
Become empty or void of its content;
The room emptied
Empty
Leave behind empty; move out of;
You must vacate your office by tonight
Empty
Remove;
Empty the water
Empty
Excrete or discharge from the body
Empty
Holding or containing nothing;
An empty glass
An empty room
Full of empty seats
Empty hours
Empty
Devoid of significance or point;
Empty promises
A hollow victory
Vacuous comments
Empty
Having nothing inside;
An empty sphere
Empty
Needing nourishment;
After skipped lunch the men were empty by suppertime
Empty-bellied children
Empty
Emptied of emotion;
After the violent argument he felt empty
Empty
Empty can refer to zero length or size.
The file is empty, it has no content.
Empty
Empty indicates a defined but unpopulated state.
The dictionary is empty because it has no key-value pairs.
Common Curiosities
How is empty used in programming?
Empty is used to indicate that a data structure has been initialized but contains no elements.
Are null and empty the same?
No, null and empty are different; null is undefined, whereas empty is defined but contains no data.
How is null used in programming?
Null is often used for uninitialized variables or object references that should not point to any memory location.
Can a variable be both null and empty?
Generally, no; a variable cannot be both null and empty simultaneously.
How does a database treat empty values?
In a database, an empty value signifies that a field is initialized but contains no information.
What does null mean?
Null indicates the absence of value or an undefined state.
What does empty mean?
Empty means a variable or object is initialized but contains no elements or data.
How does a database treat null values?
In a database, null signifies that a field has no value or is undefined.
Is null a data type?
Null is not usually a data type but rather a value or state that a variable can hold.
Do all programming languages differentiate between null and empty?
Most programming languages differentiate between null and empty, although the implementation may vary.
Share Your Discovery
Previous Comparison
Garland vs. WreathNext Comparison
Nonarbitrary vs. ArbitraryAuthor Spotlight
Written by
Tayyaba RehmanTayyaba Rehman is a distinguished writer, currently serving as a primary contributor to askdifference.com. As a researcher in semantics and etymology, Tayyaba's passion for the complexity of languages and their distinctions has found a perfect home on the platform. Tayyaba delves into the intricacies of language, distinguishing between commonly confused words and phrases, thereby providing clarity for readers worldwide.