{"id":21051578,"url":"https://github.com/pskinnertech/qrcode-vanilla","last_synced_at":"2026-04-24T21:31:45.814Z","repository":{"id":232990656,"uuid":"629229044","full_name":"PSkinnerTech/qrcode-vanilla","owner":"PSkinnerTech","description":"Create a Static QR Code Generator using Vanilla JavaScript, HTML, and Tailwind CSS","archived":false,"fork":false,"pushed_at":"2023-04-17T22:36:55.000Z","size":17,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-11T10:13:21.120Z","etag":null,"topics":["javascript","qrcode-generator"],"latest_commit_sha":null,"homepage":"https://qrcode-vanilla.netlify.app/","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PSkinnerTech.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2023-04-17T22:31:17.000Z","updated_at":"2025-01-07T08:34:24.000Z","dependencies_parsed_at":"2024-04-12T22:05:01.876Z","dependency_job_id":null,"html_url":"https://github.com/PSkinnerTech/qrcode-vanilla","commit_stats":null,"previous_names":["pskinnertech/qrcode-vanilla"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/PSkinnerTech/qrcode-vanilla","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PSkinnerTech%2Fqrcode-vanilla","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PSkinnerTech%2Fqrcode-vanilla/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PSkinnerTech%2Fqrcode-vanilla/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PSkinnerTech%2Fqrcode-vanilla/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PSkinnerTech","download_url":"https://codeload.github.com/PSkinnerTech/qrcode-vanilla/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PSkinnerTech%2Fqrcode-vanilla/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32241591,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-24T13:21:15.438Z","status":"ssl_error","status_checked_at":"2026-04-24T13:21:15.005Z","response_time":64,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript","qrcode-generator"],"created_at":"2024-11-19T15:58:21.363Z","updated_at":"2026-04-24T21:31:45.800Z","avatar_url":"https://github.com/PSkinnerTech.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Create a Static QR Code Generator using Vanilla JavaScript, HTML, and Tailwind CSS\n\n![Screenshot 2023-04-17 at 5 15 33 PM](https://user-images.githubusercontent.com/78289253/232625173-78b8f3ca-d740-4b51-9842-a3e4b02253a1.png)\n\n## Creating a User-Friendly QR Code Generator: Building a Static Web Application with Vanilla JavaScript, HTML, and Tailwind CSS\n\nIn this tutorial, we will create a static QR Code Generator application using vanilla JavaScript, HTML, and Tailwind CSS. The application will allow users to enter a URL, generate a QR code, and download the QR code as an image.\n\n## **Prerequisites**\n\nBefore starting this tutorial, you should have a basic understanding of:\n\n- HTML\n- CSS\n- JavaScript\n\n## **Setting up the project**\n\n1. Create a new folder called `qr-code-generator`.\n2. Inside the `qr-code-generator` folder, create the following files and folders:\n\n```bash\ncodeqr-code-generator/\n|-- img/\n|   |-- qrcode.svg\n|-- js/\n|   |-- script.js\n|-- index.html\n```\n\n## **Creating the HTML structure**\n\nOpen the `index.html` file and add the following code:\n\n```xml\n\u003c!DOCTYPE html\u003e\n\u003chtml lang=\"en\"\u003e\n  \u003chead\u003e\n    \u003cmeta charset=\"UTF-8\" /\u003e\n    \u003cmeta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\" /\u003e\n    \u003cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" /\u003e\n    \u003cmeta\n      name=\"description\"\n      content=\"Generate a QR code image to point to a website URL\"\n    /\u003e\n    \u003cmeta\n      name=\"keywords\"\n      content=\"qr code, qr codes, qrcodes, create qr code, qr code generator, create qrcodes, make a qr code, online qr code\"\n    /\u003e\n    \u003clink rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/favicon.ico\" /\u003e\n    \u003clink rel=\"preconnect\" href=\"https://fonts.googleapis.com\" /\u003e\n    \u003clink rel=\"preconnect\" href=\"https://fonts.gstatic.com\" crossorigin /\u003e\n    \u003clink\n      href=\"https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;700\u0026display=swap\"\n      rel=\"stylesheet\"\n    /\u003e\n    \u003cscript src=\"https://cdn.tailwindcss.com\"\u003e\u003c/script\u003e\n    \u003cscript\u003e\n      tailwind.config = {\n        theme: {\n          extend: {\n            fontFamily: {\n              sans: [\"Poppins\", \"sans-serif\"],\n            },\n          },\n        },\n      };\n    \u003c/script\u003e\n    \u003cscript\n      src=\"https://cdnjs.cloudflare.com/ajax/libs/qrcodejs/1.0.0/qrcode.min.js\"\n      integrity=\"sha512-CNgIRecGo7nphbeZ04Sc13ka07paqdeTu0WR1IM4kNcpmBAUSHSQX0FslNhTDadL4O5SAGapGt4FodqL8My0mA==\"\n      crossorigin=\"anonymous\"\n      referrerpolicy=\"no-referrer\"\n    \u003e\u003c/script\u003e\n    \u003cscript src=\"js/script.js\" defer\u003e\u003c/script\u003e\n    \u003cstyle\u003e\n      #spinner {\n        display: none;\n      }\n    \u003c/style\u003e\n    \u003ctitle\u003eFree Online QR Code Generator\u003c/title\u003e\n  \u003c/head\u003e\n  \u003cbody\u003e\n    \u003cheader class=\"p-4 mb-10 bg-green-500\"\u003e\n      \u003cdiv class=\"max-w-5xl m-auto\"\u003e\n        \u003cdiv class=\"text-xl font-bold text-white\"\u003eQR Code Generator\u003c/div\u003e\n      \u003c/div\u003e\n    \u003c/header\u003e\n    \u003cimg src=\"img/spinner.svg\" alt=\"\" /\u003e\n    \u003cmain\u003e\n      \u003cdiv\n        class=\"flex flex-col-reverse align-center justify-center m-auto md:max-w-4xl p-10 md:flex-row\"\n      \u003e\n        \u003cdiv class=\"w-full md:w-2/3 mr-24\"\u003e\n          \u003ch1 class=\"text-3xl font-bold mb-5 md:text-4xl\"\u003eQR Code Generator\u003c/h1\u003e\n          \u003cp class=\"mb-4\"\u003e\n            QR Codes allow smartphone users to access your website simply and\n            quickly.\n          \u003c/p\u003e\n          \u003cp\u003e\n            Enter your URL below to generate a QR Code and download the image.\n          \u003c/p\u003e\n\n          \u003cform id=\"generate-form\" class=\"mt-4\"\u003e\n            \u003cinput\n              id=\"url\"\n              type=\"url\"\n              placeholder=\"Enter a URL\"\n              class=\"w-full border-2 border-gray-200 rounded p-3 text-grey-dark mr-2 focus:outline-none mb-5\"\n              required\n            /\u003e\n\n            \u003cselect\n              class=\"w-full border-2 border-gray-200 rounded p-3 text-grey-dark mr-2 focus:outline-none\"\n              name=\"size\"\n              id=\"size\"\n            \u003e\n              \u003coption value=\"100\"\u003e100x100\u003c/option\u003e\n              \u003coption value=\"200\"\u003e200x200\u003c/option\u003e\n              \u003coption value=\"300\" selected\u003e300x300\u003c/option\u003e\n              \u003coption value=\"400\"\u003e400x400\u003c/option\u003e\n              \u003coption value=\"500\"\u003e500x500\u003c/option\u003e\n              \u003coption value=\"600\"\u003e600x600\u003c/option\u003e\n              \u003coption value=\"700\"\u003e700x700\u003c/option\u003e\n            \u003c/select\u003e\n            \u003cbutton\n              class=\"bg-gray-600 rounded w-full text-white py-3 px-4 mt-5 hover:bg-black\"\n              type=\"submit\"\n            \u003e\n              Generate QR Code\n            \u003c/button\u003e\n          \u003c/form\u003e\n        \u003c/div\u003e\n        \u003cdiv class=\"w-full md:w-1/3 self-center\"\u003e\n          \u003cimg\n            class=\"w-1/2 m-auto mb-10 md:w-full\"\n            src=\"img/qrcode.svg\"\n            alt=\"\"\n          /\u003e\n        \u003c/div\u003e\n      \u003c/div\u003e\n\n      \u003cdiv\n        id=\"generated\"\n        class=\"max-w-5xl m-auto flex flex-col text-center align-center justify-center mt-20\"\n      \u003e\n        \u003c!-- Spinner --\u003e\n        \u003cdiv id=\"spinner\" role=\"status\"\u003e\n          \u003csvg\n            class=\"inline mr-2 w-24 h-24 text-gray-200 animate-spin dark:text-gray-600 fill-pink-600\"\n            viewBox=\"0 0 100 101\"\n            fill=\"none\"\n            xmlns=\"http://www.w3.org/2000/svg\"\n          \u003e\n            \u003cpath\n              d=\"M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z\"\n              fill=\"currentColor\"\n            /\u003e\n            \u003cpath\n              d=\"M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z\"\n              fill=\"currentFill\"\n            /\u003e\n          \u003c/svg\u003e\n          \u003cspan class=\"sr-only\"\u003eLoading...\u003c/span\u003e\n        \u003c/div\u003e\n\n        \u003cdiv id=\"qrcode\" class=\"m-auto\"\u003e\u003c/div\u003e\n      \u003c/div\u003e\n    \u003c/main\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n```\n\n## **Styling the application with Tailwind CSS**\n\nWe have already included the Tailwind CSS CDN in the `\u003chead\u003e` section of our HTML file. We have also added a custom font, Poppins, from Google Fonts. The application should now be styled with Tailwind CSS.\n\n## **Adding interactivity with JavaScript**\n\nWe have already added the script tag for qrcode.js library and included our custom `script.js` file with the `defer` attribute in the `\u003chead\u003e` section. Open the `script.js` file and add the following code:\n\n```javascript\nconst form = document.getElementById(\"generate-form\");\nconst qr = document.getElementById(\"qrcode\");\n\n// Button submit\nconst onGenerateSubmit = (e) =\u003e {\n  e.preventDefault();\n\n  clearUI();\n\n  const url = document.getElementById(\"url\").value;\n  const size = document.getElementById(\"size\").value;\n\n  // Validate url\n  if (url === \"\") {\n    alert(\"Please enter a URL\");\n  } else {\n    showSpinner();\n    // Show spinner for 1 sec\n    setTimeout(() =\u003e {\n      hideSpinner();\n      generateQRCode(url, size);\n\n      // Generate the save button after the qr code image src is ready\n      setTimeout(() =\u003e {\n        // Get save url\n        const saveUrl = qr.querySelector(\"img\").src;\n        // Create save button\n        createSaveBtn(saveUrl);\n      }, 50);\n    }, 1000);\n  }\n};\n\n// Generate QR code\nconst generateQRCode = (url, size) =\u003e {\n  const qrcode = new QRCode(\"qrcode\", {\n    text: url,\n    width: size,\n    height: size,\n  });\n};\n\n// Clear QR code and save button\nconst clearUI = () =\u003e {\n  qr.innerHTML = \"\";\n  const saveBtn = document.getElementById(\"save-link\");\n  if (saveBtn) {\n    saveBtn.remove();\n  }\n};\n\n// Show spinner\nconst showSpinner = () =\u003e {\n  const spinner = document.getElementById(\"spinner\");\n  spinner.style.display = \"block\";\n};\n\n// Hide spinner\nconst hideSpinner = () =\u003e {\n  const spinner = document.getElementById(\"spinner\");\n  spinner.style.display = \"none\";\n};\n\n// Create save button to download QR code as image\nconst createSaveBtn = (saveUrl) =\u003e {\n  const link = document.createElement(\"a\");\n  link.id = \"save-link\";\n  link.className =\n    \"bg-green-500 hover:bg-black text-white font-bold py-2 rounded w-1/3 m-auto my-5\";\n  link.href = saveUrl;\n  link.download = \"qrcode\";\n  link.innerHTML = \"Save Image\";\n  document.getElementById(\"generated\").appendChild(link);\n};\n\nhideSpinner();\n\nform.addEventListener(\"submit\", onGenerateSubmit);\n```\n\nThis code handles the following functionality:\n\n- Form submission\n- Generating the QR code\n- Displaying and hiding the spinner\n- Creating a save button to download the generated QR code\n\n## Conclusion\n\nIn this tutorial, we have built a static QR Code Generator using vanilla JavaScript, HTML, and Tailwind CSS. We have implemented form submission, QR code generation, and the ability to download the QR code as an image. This application provides a simple and efficient way for users to generate QR codes for URLs.\n\nYou can now use this QR Code Generator to create QR codes for your website or any other URLs you want to share quickly and easily. The application is easy to customize and extend, so feel free to make any adjustments or add new features to suit your needs.\n\nIf you enjoyed this tutorial, be sure to follow me on [Twitter](https://twitter.com/PSkinnerTech) and subscribe to my blog!\n\nHappy Building! (🧱 , 🚀 )\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpskinnertech%2Fqrcode-vanilla","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpskinnertech%2Fqrcode-vanilla","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpskinnertech%2Fqrcode-vanilla/lists"}