Most “it doesn’t work” bugs between systems come down to text formats: a missing comma in JSON, a space that wasn’t URL-encoded, a timestamp in the wrong unit. Here’s a quick, practical tour.
JSON
JSON (RFC 8259) is the default format for APIs and configuration. Its rules are strict:
- Keys and strings use double quotes — never single quotes.
- No trailing commas and no comments.
- Numbers can’t have leading zeros;
NaN,Infinityandundefinedaren’t allowed. - Object keys should be unique. Most parsers silently keep the last duplicate, which hides bugs.
Use the JSON validator to find errors by line and column (including duplicate keys), and the JSON formatter to pretty-print or minify.
Base64
Base64 (RFC 4648) represents binary data using 64 safe text characters, so it can travel inside JSON, email or a data: URI. Every 3 bytes become 4 characters, making data about 33% larger. The URL-safe variant swaps +/ for -_ and often drops = padding — you’ll see it in JWTs.
A common bug: encoding text with btoa() in JavaScript fails on non-ASCII characters such as “é” or emoji. Convert to UTF-8 bytes first. The Base64 encoder does this correctly, and the Base64 decoder reverses it.
URL (percent) encoding
URLs can only contain certain characters (RFC 3986). Others are written as % plus two hex digits per UTF-8 byte: a space is %20, é is %C3%A9.
- Encode each value you put into a query string with
encodeURIComponent— it also escapes&,=and/. - Use
encodeURIonly to tidy a complete URL while keeping its structure. - HTML forms encode spaces as
+in query strings.
Try both with the URL encoder, and unpick encoded links with the URL decoder.
HTML entities
When text is placed inside HTML, < and & (and quotes in attributes) must be written as entities — <, &, " — or the browser treats them as markup. This is a key defence against cross-site scripting, though context matters (URLs and scripts need different handling). See the HTML entity encoder and HTML entity decoder.
UUIDs
UUIDs are 128-bit identifiers written as 36 characters. v4 is fully random; v7 (RFC 9562) starts with a timestamp, so new IDs sort in creation order — friendlier for database indexes. Generate either with the UUID generator.
Unix timestamps
A Unix timestamp counts seconds since 1 January 1970 UTC. JavaScript uses milliseconds, so 1767225600 (seconds) and 1767225600000 (ms) are the same moment. Store times in UTC and convert for display — South Africa is UTC+2 all year. Check values with the Unix timestamp converter.
Regular expressions
When you need to validate or extract patterns — phone numbers, IDs, dates — test your expression on real samples first. Watch out for nested quantifiers like (a+)+, which can hang on some inputs. The regex tester highlights matches, shows capture groups and stops runaway patterns.