How to Build a QR Code Generator and Reader Using JavaScript?
A QR Code API allows you to programmatically generate QR codes from text, URLs, or other data. One of the most popular free and simple APIs is provided by goqr.me.
https://api.qrserver.com/v1/create-qr-code/?data=YOUR_DATA&size=150×150
data: The content you want to encode in the QR code (e.g., URL, text).
size: The width and height of the QR image in pixels (e.g., 150×150).
If you want to generate a QR code for https://example.com, use:
https://api.qrserver.com/v1/create-qr-code/?data=https://example.com&size=200×200
How to Use in JavaScript
You can use this API in your HTML/JS project like this:
const data = „https://example.com„;
const size = „200×200“;
const url = https://api.qrserver.com/v1/create-qr-code/?data=${encodeURIComponent(data)}&size=${size}
;
document.getElementById(„qrCode“).src = url;