🔢 JSON Data Types
Estimated reading: 3 minutes 320 views

JSON Boolean – True/False Values in JSON Explained (2025 Guide)


Introduction – What is a Boolean in JSON?

In JSON (JavaScript Object Notation), a boolean is a data type that holds one of two values: true or false. Booleans are used to represent binary states—such as on/off, yes/no, enabled/disabled—making them essential for decision-making in data structures, APIs, and configurations.

In this guide, you’ll learn:

  • What boolean values are in JSON
  • How to write valid booleans
  • How JSON booleans are used in real examples
  • How they are handled in JavaScript and other programming languages

JSON Boolean – Format and Syntax

JSON only allows two boolean values:

  • true
  • false

Syntax Rules:

  • Must be written in lowercase (true, false)
  • No quotes around the value (unlike strings)
  • Cannot be spelled with capital letters (True, False are invalid)
  • Cannot use numbers like 1 or 0 as a substitute

Example – JSON Object with Booleans

{
  "isActive": true,
  "isAdmin": false,
  "subscribed": true
}

Explanation:

  • "isActive": true → The user is active
  • "isAdmin": false → The user is not an admin
  • "subscribed": true → The user has an active subscription

JSON Boolean in JavaScript

When you parse a JSON string containing booleans in JavaScript, they are automatically converted to native JavaScript boolean types.

Example:

const json = '{ "loggedIn": true, "premiumUser": false }';
const user = JSON.parse(json);

console.log(user.loggedIn);     // Output: true
console.log(typeof user.loggedIn); // Output: boolean

Explanation:

  • JSON.parse() converts the JSON string into a JavaScript object
  • Boolean values remain true or false, not converted to strings

Invalid JSON Boolean Examples

Here are some common mistakes that cause invalid boolean values in JSON:

{
  "flag": "true"     //  Invalid – value is a string, not a boolean
}
{
  "enabled": True     //  Invalid – JSON booleans must be lowercase
}

Corrected Version:

{
  "flag": true,
  "enabled": false
}

Summary – Recap & Next Steps

Booleans in JSON are simple and powerful. They let you represent two-state values clearly and reliably across different programming environments.

Key Takeaways:

  • JSON booleans can only be true or false (no quotes)
  • Always write them in lowercase
  • Do not use "true" as a string or 1/0 as a substitute
  • They automatically map to native booleans in JavaScript and most languages

Real-world use:

JSON booleans are widely used in user settings, feature toggles, authentication states, and API flags like "success": true.


FAQ – JSON Boolean


What values are valid booleans in JSON?
Only two: true and false. Both must be lowercase and unquoted.


Can I use "true" as a boolean in JSON?
No. "true" is a string, not a boolean. It will be parsed as text.


Are 1 and 0 valid booleans in JSON?
No. JSON does not allow using integers as boolean values.


How do JSON booleans behave in JavaScript?
They become native true or false boolean values when parsed with JSON.parse().


Share Now :
Share

Json Boolean

Or Copy Link

CONTENTS
Scroll to Top