Luke Oliff.

TIL: Generating QR Codes in the Terminal With qrencode

·TIL·1 min read·Luke Oliff

QR codes look like magic until you generate one from the terminal.

qrencode -o qr.png 'https://example.com/callback'

That is it. One command, one PNG file. Scan it with any phone and it opens the URL.

qrencode -t ANSI256 'https://example.com/callback'

The -t ANSI256 flag renders the QR code as coloured blocks in the terminal. Handy for demos where you do not want to open a file browser.

I used qrencode when testing Vonage’s SMS and voice callback URLs. Generate a QR code for the webhook testing URL on my laptop, scan it on my phone, trigger the API call from the phone. Fast feedback loop.

How do I install qrencode?

brew install qrencode

Can it encode more than URLs?

Any text. WiFi credentials, contact details, plain notes. The input is just a string.