2026-09-23 · 6 min read · Rahul Chitturi
- json-schema
- base64
- validation
JSON Schema can describe a string's transfer encoding, media type, and decoded structure with contentEncoding, contentMediaType, and contentSchema. A schema may look strict while a validator treats some or all of those keywords as annotations.
Failures also appear when producers disagree about Base64 alphabets, padding, text encodings, or whether validation applies before or after decoding.
Identify each processing layer
Record the schema dialect, vocabulary support, validator options, JSON string value, declared encoding, declared media type, decoded bytes, and application parser. Confirm which component performs every check instead of assuming the schema engine decodes content.
- Validate the outer value as a JSON string first.
- Distinguish standard Base64 from Base64url.
- Set decoded size limits before parsing.
- Treat media type as a policy input, not proof of safety.
Reduce the failing fixture
Test a harmless payload with a known byte sequence. Compare padded and unpadded forms, invalid alphabet characters, whitespace, empty content, non-UTF-8 bytes, media type parameters, and a decoded document that violates contentSchema.
If validators disagree, inspect their documented dialect and content-vocabulary behavior. Do not silently replace a production validator merely to obtain the desired result.
Inspect safely in the browser
Use Flashman's JSON formatter for the schema and instance, Base64 tool for synthetic payloads, diff for validator fixtures, and hash tool for public byte comparisons.
Keep credentials, personal documents, and production payloads out of shared examples. Decoding or parsing content does not make it trustworthy; apply normal file, media, and structured-data security controls afterward.