Toolpal

@toolpal/qr-code

public

v2.0published 1 download this weekMIT

Generates a scannable QR code image (PNG or SVG) offline for any text: a URL, a Wi-Fi login (WIFI:T:WPA;S:<network>;P:<password>;;), a vCard, a phone number (tel:...), an email (mailto:...) or plain text. Returns the image file. No API key needed.

Generates a scannable ISO/IEC 18004 QR code image (PNG or SVG) completely offline — no API key, no network access, and zero external dependencies.

How it works

  1. Encodes any UTF-8 text (URL, Wi-Fi config, vCard, tel:, mailto:, or plain text) into the smallest QR version (1–40) that fits at the chosen error correction level (L, M, Q, or H).
  2. Evaluates all 8 standard mask patterns and picks the lowest-penalty pattern for reliable scanning.
  3. Renders either a crisp PNG (with configurable pixel scale) or a scalable SVG file with a 4-module quiet zone.

Example

{
  "text": "https://toolpal.dev",
  "errorCorrection": "M",
  "format": "png",
  "scale": 10
}

Returns:

{
  "image": "out/qr-code.png",
  "version": 2,
  "modules": 25,
  "errorCorrection": "M",
  "bytes": 19
}

Notes

  • Runs 100% offline (net: false, no environment variables required).
  • Supports up to 2,953 bytes of UTF-8 text (at error correction level L).
  • Wi-Fi QR format: WIFI:T:WPA;S:<network>;P:<password>;;.

Input

Validated before the workflow runs.

  • textrequiredstring

    What the QR code should contain

    min length 1 · max length 2953

  • scaleinteger

    PNG pixels per QR module, 10 by default

    ≥ 1 · ≤ 20

  • format"png" | "svg"

    Image format, png by default

  • errorCorrection"L" | "M" | "Q" | "H"

    How much damage the code survives: L 7%, M 15% (default), Q 25%, H 30%. Higher means a denser code.

JSON Schema
{
  "type": "object",
  "required": [
    "text"
  ],
  "properties": {
    "text": {
      "type": "string",
      "maxLength": 2953,
      "minLength": 1,
      "description": "What the QR code should contain"
    },
    "scale": {
      "type": "integer",
      "maximum": 20,
      "minimum": 1,
      "description": "PNG pixels per QR module, 10 by default"
    },
    "format": {
      "anyOf": [
        {
          "type": "string",
          "const": "png"
        },
        {
          "type": "string",
          "const": "svg"
        }
      ],
      "description": "Image format, png by default"
    },
    "errorCorrection": {
      "anyOf": [
        {
          "type": "string",
          "const": "L"
        },
        {
          "type": "string",
          "const": "M"
        },
        {
          "type": "string",
          "const": "Q"
        },
        {
          "type": "string",
          "const": "H"
        }
      ],
      "description": "How much damage the code survives: L 7%, M 15% (default), Q 25%, H 30%. Higher means a denser code."
    }
  }
}

Output

Validated before your agent receives it.

  • bytesrequiredinteger

    Bytes of UTF-8 data encoded

  • imagerequiredfile

    Generated QR code image (.png or .svg)

  • modulesrequiredinteger

    Width of the code in modules, without the quiet zone

  • versionrequiredinteger

    QR version, 1 (21x21) to 40 (177x177)

  • errorCorrectionrequiredstring
JSON Schema
{
  "type": "object",
  "required": [
    "image",
    "version",
    "modules",
    "errorCorrection",
    "bytes"
  ],
  "properties": {
    "bytes": {
      "type": "integer",
      "description": "Bytes of UTF-8 data encoded"
    },
    "image": {
      "type": "string",
      "description": "Generated QR code image (.png or .svg)",
      "x-toolpal-file": true
    },
    "modules": {
      "type": "integer",
      "description": "Width of the code in modules, without the quiet zone"
    },
    "version": {
      "type": "integer",
      "description": "QR version, 1 (21x21) to 40 (177x177)"
    },
    "errorCorrection": {
      "type": "string"
    }
  }
}