pipr.tools

qr-encode

Generate a QR code as SVG from text

{ } Encode

Try it

stdin0 chars
stdout0 chars

Flags

--ecl select: L | M | Q | H default: M
--margin number default: 4
--width number default: 0

Example

Generate a QR code for a URL

Usage
$ echo "https://pipr.tools" | qr-encode
View source
async (input, opts = {}) => {
      if (!input.trim()) return "";
      try {
        const qrOpts = {
          type: "svg",
          errorCorrectionLevel: opts.ecl || "M",
          margin: parseInt(opts.margin) || 4,
        };
        const w = parseInt(opts.width);
        if (w > 0) qrOpts.width = w;
        return await QRCode.toString(input, qrOpts);
      } catch (e) {
        return `Error: ${e.message}`;
      }
    }

Dependencies

Suggested Pipelines

Related Tools