Developer guides and tutorials
Practical articles on JSON, encoding, regex, cron, CSS layout and more. Each one pairs with a free tool you can try right in your browser.
38 articles
JSON
6 articlesHow to pretty print JSON in JavaScript, Python and the terminal
JSON.stringify's third argument, Python's json.dumps, jq and python -m json.tool: how to indent JSON, sort keys and avoid the errors that stop formatting.
How to check if a string is valid JSON
A try/catch around JSON.parse is the standard check, but it has edge cases: bare numbers, null, duplicate keys and error positions. Here's a validator that handles them.
How to reduce JSON payload size
Minifying JSON helps less than you'd think once compression is on. Here's how to measure your payloads and which changes actually make API responses smaller.
How to type API responses in TypeScript
response.json() returns any, and a cast only tells the compiler what you hope. Here's how to go from a sample response to types that are checked at runtime.
How to compare two JSON objects and find what changed
JSON.stringify(a) === JSON.stringify(b) breaks when keys move. Here's a deep equality check for JSON data, a function that lists every changed path, and CLI options.
JSON Schema validation in JavaScript with Ajv
A JSON Schema describes what valid data looks like; Ajv checks data against it quickly and reports exactly what's wrong. Here's a working setup, the keywords you'll use most and common pitfalls.
Encoding
4 articlesJWT decode vs verify: reading a token isn't trusting it
Anyone can decode a JWT. Only verification proves who issued it and that it wasn't changed. Here's what each step checks and the mistakes that turn decode into a security hole.
Base64 encoding explained
Base64 turns any bytes into 64 safe characters. Here's how the 3-to-4 conversion works, what the = padding means, how Base64URL differs, and how to handle Unicode in JavaScript.
encodeURI vs encodeURIComponent
One encodes a whole URL and leaves its structure alone; the other encodes a single piece and escapes everything. Using the wrong one breaks query strings in subtle ways.
Escaping HTML in JavaScript to prevent XSS
Escaping five characters stops most injection into HTML text, but only in the right context. Here's a correct escape function, when to avoid it entirely, and the places where it isn't enough.
Generators
8 articlesUUID v4 vs UUID v7: choosing an ID for your database
Random v4 UUIDs scatter inserts across your index; v7 UUIDs sort by creation time. Here's how they differ, when the difference matters, and what each reveals.
Cron syntax cheat sheet
Every crontab field, operator and shortcut on one page, with examples, the day-of-month OR day-of-week rule that surprises everyone, and how Quartz and cloud schedulers differ.
How to generate a secure random password in JavaScript
Math.random() is predictable, and a naive modulo skews the odds. Here's how to generate passwords and tokens correctly with Web Crypto, and how long they need to be.
A practical guide to CSS gradients
Gradients are images generated by CSS. Here's how the three gradient functions work, how to place color stops, and how to build stripes, pie charts, text effects and smoother blends.
A practical guide to CSS box-shadow
One box-shadow value has up to six parts, and good-looking shadows usually stack several. Here's the syntax, layered shadow recipes, an elevation scale, and when to use drop-shadow instead.
CSS flexbox cheat sheet
All the flexbox properties for containers and items, what flex: 1 really means, the patterns you'll use daily (centering, navbars, sticky footers) and fixes for overflow and shrinking bugs.
CSS grid tutorial with practical examples
Grid places items in rows and columns at the same time. This tutorial builds real layouts step by step: card grids, a holy grail page, featured items and named areas.
CSS keyframe animations: a practical guide
@keyframes defines the steps, the animation property controls timing and repetition. Here's how both work, which properties animate smoothly, and how to respect users who prefer less motion.
Text
1 articleJavaScript regex cheat sheet
Every piece of JavaScript regex syntax you reach for, from character classes to named groups and lookbehind, plus the string methods that use them and the mistakes they cause.
Converters
7 articlesWorking with Unix timestamps in JavaScript
JavaScript counts time in milliseconds, most APIs in seconds. Here's how to convert between them, read timestamps as dates in UTC or local time, and avoid the classic parsing bugs.
How to convert JSON to CSV in JavaScript and Python
A JSON-to-CSV conversion looks like five lines of code until you hit commas in values, nested objects, missing keys, Excel encodings and formula injection. Here's code that handles them.
Copy as cURL: replaying browser requests from DevTools
Every browser can copy a network request as a curl command. Here's how to use it to reproduce API bugs, which headers you can safely delete, and how to avoid leaking session cookies.
HEX vs RGB vs HSL in CSS
HEX, RGB and HSL can all describe the same sRGB colors. The difference is how easy they are to read and adjust. Here's how each works, how to convert, and when to reach for OKLCH.
How to parse CSV in JavaScript
Splitting lines on commas works until a value contains a comma, a quote or a line break. Here's how CSV quoting really works, a parser that handles it, and when to use a library.
YAML vs JSON: differences and when to use each
YAML is a superset of JSON built for humans; JSON is a strict format built for machines. Here's how they differ, the YAML type surprises that break configs, and which to pick.
px vs rem vs em in CSS
Pixels are fixed, rem follows the root font size, em follows the parent. Here's how each behaves when users change their browser's text size, and a simple rule for when to use which.
Code
9 articlesHow to minify CSS
Minifying CSS removes whitespace and rewrites values into shorter forms. Here's what a good minifier changes, how to add one to your build, and the optimizations that save more.
JavaScript minification with Terser
Minifiers do more than strip whitespace: they rename variables, remove dead code and rewrite expressions. Here's what Terser does, which options matter, and how to avoid breaking your code.
SQL formatting best practices
Consistent SQL is easier to review, debug and diff. Here's a style that works for most teams, with before-and-after examples and tools that apply it for you.
HTML vs JSX: the differences that matter
JSX looks like HTML but compiles to JavaScript, which explains every difference: className, camelCase events, style objects, closed tags and the attributes React handles differently.
GitHub Flavored Markdown cheat sheet
The Markdown syntax you use in READMEs, issues and docs, including the GitHub extensions for tables, task lists and strikethrough, and the line break and HTML rules that trip people up.
How to convert HTML to Markdown in JavaScript and Python
Migrating a CMS, archiving docs or feeding pages to an LLM all need clean Markdown from HTML. Here's how to do it with Turndown and Python libraries, and how to handle tables, code and page clutter.
Open Graph meta tags: a complete guide
Open Graph tags decide the title, description and image people see when your link is shared. Here's the minimal set, image requirements, framework examples and fixes for stale previews.
How to pretty print XML
Indenting XML makes SOAP responses, sitemaps, feeds and config files readable, but whitespace can be data. Here's how to format XML from the command line and in code without changing what it means.
Common YAML errors and how to fix them
Most YAML errors come from a handful of causes: tabs, inconsistent indentation, colons and special characters in plain values, and duplicate keys. Here's what each error message means and the fix.
Security
1 articleSHA-256 hashing in JavaScript with Web Crypto
Browsers and Node.js can compute SHA-256 without any library. Here's how to hash text and files, convert the result to hex, sign data with HMAC, and why passwords need a different algorithm.
Reference
2 articles401 vs 403: which status code to return, and why
401 asks the client to authenticate; 403 says authenticating won't help. Here's how to choose between them in an API, what WWW-Authenticate is for, and how clients should react to each.
HTTP redirects explained: 301, 302, 303, 307 and 308
Five status codes redirect a request, and they differ in two ways: whether the move is permanent and whether a POST stays a POST. Here's which to use for domain moves, HTTPS, forms and APIs.