JSON has no built-in way to mark a field as required. The format itself only describes values: objects, arrays, strings, numbers, booleans, and null. Whether a key must be present is a rule imposed by the system reading the JSON, so "required" is always expressed in a second layer — a JSON Schema, an API contract, or a convention in the consuming code. The key condition to understand up front: "required": ["email"] in JSON Schema means the email key must exist, but it says nothing about whether its value is null or an empty string unless you also constrain the value.
Why JSON Cannot Enforce Required Fields on Its Own
A JSON document is just data. Parsers like JavaScript's JSON.parse or Python's json.loads will happily accept {} even when your application expected ten fields. They report syntax errors — a trailing comma, an unquoted key — but never semantic errors. That division matters when designing a contract: the JSON parser checks shape at the syntax level, and a validator or application code checks meaning at the rule level.
Because of that split, there are only a few honest places to record requirement rules:
A schema file that travels with the data or is served alongside the API. The API documentation and the server's validation logic, which are the real contract even when a schema exists. Strong typing in code — Go structs, TypeScript interfaces, Rust structs — where a missing field either fails to decode or decodes to a distinguishable zero value. Plain naming conventions in small systems where a full schema feels heavy.
Mixing several of these works, but only if one is authoritative. When a schema and the server disagree, clients will follow the schema and then get rejected, which is one of the most common causes of "required field" bugs in the field.
The Standard Approach: JSON Schema's required Array
JSON Schema (draft-07 and later, up through 2020-12) uses a required keyword holding an array of property names:
Read the semantics carefully:
required lists keys that must be present in the object instance. The array can be empty, which means no keys are required. It applies to the object in which it appears; for arrays of objects, put required inside items. Required keys do not need to be declared in properties; JSON Schema doesn't require that. But omitting an undeclared required key from properties means it has no value constraints, and some tools will warn. Declaring it is clearer. Draft-04 and earlier used a different style: requirement was expressed with "required": true inside each property definition. That draft is obsolete. If you find it in an old file, the modern required array is the rewrite target, and validators for newer drafts reject the old form.
Two details trip people up regularly. First, a property that is required but also allowed to be null needs "type": ["string", "null"]; presence and non-nullness are separate questions. Second, a required property with a default only helps if the validator or consumer actually applies defaults — validation happens against the instance as written, so a missing required key fails before any default is filled in.
Conditional requirements with dependentRequired
Sometimes a field is required only in certain circumstances. JSON Schema 2019-09 replaced the older dependencies keyword with clearer options:
dependentRequired says: if billingAddress is present, cardNumber must be too. The if/then construct covers the same ground with full condition logic. Both are still "presence" rules; neither rejects an empty string. Add "minLength": 1 if blank values should not satisfy the requirement.
Expressing Required Fields in OpenAPI and API Docs
If your JSON travels over an API described by OpenAPI 3.x, requirement is usually stated with required: true on each property of the schema object:
OpenAPI schemas also accept the JSON Schema required array, and the official specification defines the property-level boolean in the schema object. The practical rule: pick one style per project and keep generated code in sync with it. A required array and per-property booleans can coexist, but tools sometimes read only one of them, so consistency avoids silent mismatches between docs and behavior.
Server frameworks that generate schemas from code — FastAPI, Spring, NestJS with class-validator, and similar — attach requirement at the type level. In Python with Pydantic, a field without a default is required; in TypeScript with Zod, you omit .optional(); in Java with Bean Validation you add @NotNull or @NotBlank to the field. These annotations then shape both validation and generated documentation, which is a good reason to define the rule once in code rather than hand-maintaining a separate schema file.
Choosing a Representation When You Have No Schema
Small projects, configuration files, and one-off exchanges often have no schema. The honest options are conventions, and each has a cost.
Document it and validate in code. The most maintainable option. Write a function that checks presence and raises a clear error with the field name. Example in JavaScript: if (!("email" in payload)) throw new Error("email is required");. The in operator checks key presence without being fooled by falsy values like 0 or empty strings, which if (!payload.email) will mishandle. A parallel required metadata block. Some internal formats include a second document or a sibling object listing rules. This works but doubles the surface area and can drift. Prefix or suffix key names such as req_email or email!. Cheap to spot in a file, but it pollutes the data model, breaks every consumer that expects the plain name, and gives no way to express conditions. Not recommended beyond throwaway fixtures. Fake sentinel values like "", empty strings, or "". Avoid these. They convert a missing field into an invalid value, and downstream code has to guess whether "" means "required placeholder" or "intentionally empty."
A comment convention is the weakest option: JSON has no comments, so anything like // or _comment keys gets parsed as real data or breaks the file. JSON5 and JSONC allow comments, but they are not JSON and many strict parsers refuse them.
Writing Requirement Checks That Match the Rule
The gap between "key present" and "meaningful value" is where most bugs live. Decide which of these the rule actually means, and encode exactly that:
1: Key must exist. Check membership, not truthiness. "email" in obj or Object.prototype.hasOwnProperty.call(obj, "email") in JavaScript; "email" in doc in Python; obj.ContainsKey("email") in C#. 2: Key must exist and be non-null. Add an explicit null check. A key with value null passes a presence check. 3: Key must exist and be non-empty. Trim strings and compare length for text; for arrays and objects, a zero length is a separate rule. 4: Key must exist and satisfy a constraint. This is where format, pattern, minimum, maxLength, and enum belong.
A worked example shows why this matters. Suppose a validator applies "required": ["age"] to {"age": null}. The document passes, because age is present. If the business rule was "age must be supplied and must be a number," the schema needs "age": { "type": "integer", "minimum": 0 } with no null in the type union. Under that schema, {"age": null} fails with a type error and {} fails with a required error — two different, accurate messages.
A second failure case: an API receives {"email": ""}. Presence checks pass, so the request reaches a database that rejects the empty unique key, or worse, stores it. The rule at the boundary should have been required plus minLength: 1. State the intended rule in English first, then translate it to the schema; doing it in the other direction often encodes a weaker rule than intended.
Limits worth knowing before you rely on schema validation
Cross-field rules — "exactly one of these two contacts," "end date after start date," "at least one item" — are expressible but become verbose and error-prone in JSON Schema. Some rules need oneOf/anyOf combinations or custom code. Defaults don't satisfy required. As noted, a default applies after validation in several validator implementations, so a missing required field still errors. Check your validator's documented behavior rather than assuming. required is not supported everywhere. Some older tooling or loosely compliant validators ignore or partially support if/then. If compatibility matters, keep conditional logic minimal and test with the validators you actually deploy. Boolean schemas and extra keys. additionalProperties: false is a separate keyword; it prohibits unknown keys, not absent ones. Don't confuse the two. Formats are annotations in some drafts. format: "email" is not always enforced by default. If email validity is a requirement, add a pattern or enable format assertion in the validator.
Validating and Checking the Rule Worked
For a schema-bearing project, a simple check is to feed the validator a set of test documents and confirm each gets the expected verdict. The pattern is identical in Python, Node, Java, and Go:
1: Write a minimal valid instance and confirm it passes. 2: Remove one required key and confirm the error names that key — not a generic failure. 3: Set a required key to null, then to "", then to a wrong type, and confirm each is caught if your rule intended to catch it. 4: For conditional rules, exercise both branches of the if.
In Node, a validator like Ajv turns a schema into a function; its error objects carry an instancePath and a keyword such as "required", which is the signal that a presence rule (not a type rule) failed. In Python, jsonschema raises ValidationError with .validator == "required" and a message naming the missing property. If your test sees a "type" error where you expected "required", you've written a value rule where you meant a presence rule.
If you have no schema, the success check is that the validation function's error names the field and the operation refuses to proceed — before any partial write to a database or downstream service. The wrong symptom is discovering the problem after a record has been stored with a placeholder.
When the rule matters a lot — payments, identity, regulated data — the stop condition is that hand-written validation and documentation keep disagreeing. At that point a machine-readable schema with automated tests is the stable fix, and if your team can't maintain it, the requirement rules need a single owner rather than another layer of checks.
A Practical Checklist for Any JSON Contract
Before publishing or consuming a JSON contract, confirm:
The rule for each field is stated as one of: must exist, must exist and not be null, must exist and be non-empty, must exist and meet a value constraint. Required fields are declared in the schema's required array (or the API tool's equivalent) and also present in properties with their value rules. Conditional requirements use dependentRequired, if/then, or server code that is tested on both branches. The server validates at the boundary using the same schema clients see. Tests cover the missing-key, null, empty-string, and wrong-type cases for each required field. No fake placeholders and no reliance on JSON comments.
The summary you can carry away: JSON doesn't mark fields required; your contract does. The required keyword controls presence, value keywords control meaning, and the server or application is the final judge — so keep all three pointing at one written rule, and check the error messages to confirm which rule actually fired.