Seven everyday dev chores, before and after: the one-liner vs the browser tab
Most of my small daily annoyances as a developer have two answers: a one-liner I half remember, or a browser tab. I used to feel that the one-liner was the "real" answer. After keeping notes for a few weeks, I think each
Most of my small daily annoyances as a developer have two answers: a one-liner I half remember, or a browser tab. I used to feel that the one-liner was the "real" answer. After keeping notes for a few weeks, I think each has its place, and the line between them is clearer than I expected.
I wrote this with AI help and ran every command myself, on Ubuntu with GNU coreutils 8.32, jq 1.6, Python 3.10 and Node 24. The outputs below are pasted as they came out. The browser tools are on theomnikit.com, a site I build; each runs in the browser, so what you paste stays on your machine.
1. Read a JWT
Manual way. With the well-known jwt.io sample token in $TOKEN, the obvious move half-fails, because JWTs use base64url without padding:
$ echo "$TOKEN" | cut -d. -f2 | base64 -d
{"sub":"1234567890","name":"John Doe","iat":1516239022}base64: invalid input
Node handles base64url directly:
$ node -e 'const p=process.argv[1].split(".")[1];console.log(JSON.parse(Buffer.from(p,"base64url")))' "$TOKEN"
{ sub: '1234567890', name: 'John Doe', iat: 1516239022 }
Note that iat is still a raw number.
Browser way. The JWT Decoder splits the header, payload and signature, and shows exp, iat and nbf as readable dates with the time left. The page says plainly that decoding is not verifying; checking the signature needs the key, on its Verify tab.
Verdict: the Node line inside a script; the tool when the real question is "has this expired?"
2. Find where JSON breaks
Manual way.
$ printf '{"name": "api", "port": 8080,}' > bad.json
$ python3 -m json.tool bad.json
Expecting property name enclosed in double quotes: line 1 column 30 (char 29)
Accurate, but it names the symptom (a missing key), not the cause (a trailing comma).
Browser way. The JSON Validator gives the line and column of the first problem plus the likely fix, such as a trailing comma, single quotes or an unquoted key. The JSON Formatter does the same check and also indents, sorts keys or minifies.
Verdict: json.tool in CI; the validator when a human has to fix a pasted blob.
3. Convert YAML to JSON
Manual way. Needs PyYAML installed, which most machines I touch have:
$ cat c.yaml
defaults: &d
retries: 3
prod:
<<: *d
host: example.com
$ python3 -c 'import yaml,json;print(json.dumps(yaml.safe_load(open("c.yaml")),indent=2))'
{
"defaults": {
"retries": 3
},
"prod": {
"retries": 3,
"host": "example.com"
}
}
The anchor and merge key were expanded, which is what you want.
Browser way. YAML to JSON converts as you type, in both directions, with anchors, aliases and merge keys resolved and errors reported by line and column.
Verdict: Python if PyYAML is already there; the tool on a machine where it is not, or when you need JSON back to YAML.
4. Compare two JSON files
Manual way. Plain diff sees one changed line, because key order differs:
$ diff a.json b.json
1c1
< {"port":8080,"debug":false,"host":"a"}
\ No newline at end of file
---
> {"host":"a","debug":true,"port":8080}
\ No newline at end of file
Sorting keys with jq first gives the real answer:
$ diff <(jq -S . a.json) <(jq -S . b.json)
2c2
< "debug": false,
---
> "debug": true,
Browser way. JSON Diff lists every value added, removed or changed by its path, such as $.items[2].price, ignoring key order and whitespace.
Verdict: the jq pair for small flat files; the tool when the files are nested and you want paths rather than line numbers.
5. Convert an epoch timestamp
Manual way.
$ date -u -d @1700000000
Tuesday 14 November 2023 10:13:20 PM UTC
$ TZ=Asia/Kolkata date -d @1700000000
Wednesday 15 November 2023 03:43:20 AM IST
$ date -d @1700000000000
Monday 09 November 55840 03:43:20 AM IST
The last one is the trap: a millisecond value read as seconds lands in the year 55840, with no warning.
Browser way. The Unix Timestamp Converter detects seconds or milliseconds, and shows ISO 8601, RFC 2822 and local time in any zone. It also converts a date back to a timestamp.
Verdict: date when you know the unit; the tool when a log line gives you 13 digits and you are tired.
6. Hash a string
Manual way. The classic mistake, shown honestly:
$ echo hello | sha256sum
5891b5b522d5df086d0ff0b110fbd9d21bb4fc7163af34d08286a2e846f6be03 -
$ echo -n hello | sha256sum
2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824 -
echo adds a newline, so the first hash is of hello\n.
Browser way. The SHA-256 Generator hashes text or a file with the browser's Web Crypto engine, in hex or Base64. The Base64 form is the one Subresource Integrity attributes expect.
Verdict: sha256sum for files and scripts; the tool when you need Base64, or want no doubt about a trailing newline.
7. Check a regex
Manual way.
$ printf 'order-1042 shipped\norder-77 paid\nrefund-5\n' | grep -oE 'order-[0-9]+'
order-1042
order-77
$ node -e 'console.log([..."order-1042 shipped, order-77 paid".matchAll(/order-(\d+)/g)].map(m=>m[1]))'
[ '1042', '77' ]
Fine once it works. Getting there means rerunning the line after every change.
Browser way. The Regex Tester highlights matches as you type, puts numbered and named groups in a table, previews a replace and explains the pattern in plain English. It tests JavaScript regex, so check differences before pasting into Python or grep.
Verdict: grep for a quick yes or no; the tool while you are still writing the pattern.
What I took from this
The command line wins whenever the task repeats or lives in a script. The browser wins when the task is one-off and the output needs reading by a person: dates instead of numbers, paths instead of line numbers, a likely fix instead of a symptom. Three of the seven manual ways had a quiet trap (base64url padding, millisecond timestamps, the echo newline), and that, more than speed, is the case for a tool that already knows about it.
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.