A QR code generator is a small app that turns text or a link into a QR code image you can scan with a phone. It is a great beginner project because it teaches you forms, APIs, and downloading files — and the result is genuinely useful for sharing links, Wi-Fi details, or contact cards.
How does it work? The app takes text from an input, asks a QR code API to generate the image, shows it on the page, and lets the user download it. No backend needed — a free public API does the heavy work.
<!-- index.html -->
<input type="text" id="text" placeholder="Paste a link or type some text..." />
<button id="generate">Generate QR Code</button>
<div id="result">
<img id="qr" alt="Your QR code will appear here" />
</div>
<button id="download" hidden>Download QR Code</button>
// script.js — generate the QR code with a free API
const textInput = document.getElementById('text');
const qrImg = document.getElementById('qr');
const downloadBtn = document.getElementById('download');
document.getElementById('generate').addEventListener('click', () => {
const text = textInput.value.trim();
if (!text) {
alert('Please enter some text or a link first.');
return;
}
// The API returns a QR code image for any text
const url = `https://api.qrserver.com/v1/create-qr-code/?size=240x240&data=${encodeURIComponent(text)}`;
qrImg.src = url;
downloadBtn.hidden = false;
});
// Let the user download the image
downloadBtn.addEventListener('click', async () => {
const response = await fetch(qrImg.src);
const blob = await response.blob();
const link = document.createElement('a');
link.href = URL.createObjectURL(blob);
link.download = 'qr-code.png';
link.click();
});
This project teaches you a pattern you will use in many apps: take user input, call an API, show the result, and let the user save it. The same flow powers image tools, short link apps, and file converters.
The limits are worth knowing. The free API needs internet and has rate limits, so it is not the right choice for a high-traffic production app — for that, generate QR codes locally with a library like qrcode. Also, never put passwords or private data in a QR code that others can scan.
Start today: build the page above, generate a QR code for your favourite website, and scan it with your phone. Then add a size selector so users can choose a bigger or smaller code.
Top comments (0)