from Hacker News

Client-side QR code generator with SVG output

by kentbrew on 8/31/24, 5:42 PM with 31 comments

  • by toddmorey on 8/31/24, 8:59 PM

    One of my favorite components from the open source web components library Shoelace is the QR code generator: https://shoelace.style/components/qr-code
  • by boomskats on 8/31/24, 11:23 PM

    This looks great! Wish I had it a few months ago instead of having to use qr-code-styling[0] which was a bit of a pain.

    I remember it was around the same time that Obsidian got native callouts, so my notes for that project are all colourful & contain valuable admonitions like this:

    ```

    > [!todo]

    > That feeling when you're wasting hours of your life trying to make something you know is abandonware work just because it looks nice. There should be a word for that feeling. In Danish or Japanese. Or German.

    ```

    [0]: https://github.com/kozakdenys/qr-code-styling

  • by pikminguy on 9/1/24, 5:54 PM

    If you're looking for a non web QR generator with lots of options try Zint. https://www.zint.org.uk/ It's the only option I have found that doesn't seem to lock out any features. You want to control the error correction? Got it. Render in color? No problem. Batch convert 1000 lines of text into 1000 individual images. It took less than a second. It even does Datamatrix and other non QR encodings.
  • by declan_roberts on 9/1/24, 12:51 AM

    USE THIS SOFTWARE AND LEARN FROM MY MISTAKE:

    We made a cute Christmas video to include in our card this year. My wife created a QR code from a random website and included it in the card as a picture. It linked to our video. We sent all of the cards out. People loved it.

    ... except we got an email from the QR code company about a week before Christmas. We went over our "free" click (the QR code went through their URL shortener). If we wanted to keep the QR code active we had to pay $20/mo.

    We got absolutely fleeced. Never again. Control the URL and make the QR image yourself.

  • by nayuki on 8/31/24, 9:52 PM

    Thank you for building this wonderful UI on top of my library!
  • by KTibow on 8/31/24, 11:28 PM

    If you stumbled upon this looking for the smallest QR code JS library, it's probably LeanQR [0]. It's under 10kb minified and 5kb compressed.

    [0] https://qr.davidje13.com/

  • by Techbrunch on 9/1/24, 7:43 AM

    I found that Anthony Fu's QR Toolkit is a great alternative: https://qrcode.antfu.me/
  • by davchana on 9/1/24, 4:51 AM

    Pretty great example, but I was bummed to see that Error Level is missing. I like to create easy codes with low error correction.
  • by jillesvangurp on 9/1/24, 9:30 AM

    I've been using this library: https://www.npmjs.com/package/qrcode.

    Works great and it does svg too. There are a few alternatives to this around as well but this one seems good enough.

  • by butz on 9/1/24, 5:48 AM

    Isn't this one of those rare occasions where bitmap file format is more optimal for storing output?
  • by Narhzih on 9/1/24, 9:57 AM

    You can try https://app.y.gy. It's not a library, but they have an API for link-shortening and QR Code Generation.
  • by kentbrew on 8/31/24, 5:42 PM

    "The demo on this page combines Project Nayuki’s QR Code generator library (a multi-language open source project that can, among other things, perform the conversion of text into raw QR code data) with my own QRSVG project, which can turn a QR-like two-dimensional boolean data map into an efficient vector description of its own visualization by tracing the contours of contiguous shapes."
  • by the_arun on 9/1/24, 3:03 AM

    For some reason in my phone camera - "Open in browser" is not showing up if background is dark.
  • by eaq on 9/1/24, 3:36 AM

    For local use, this Python library can generate SVGs with QR codes: https://github.com/lincolnloop/python-qrcode