qrcode-rs
qrcode-rs is a Rust crate for generating QR Code and Micro QR Code symbols, rendering them in multiple output formats, and optionally decoding them back through rqrr.
It is designed to cover the common cases well out of the box while still exposing lower-level building blocks for advanced encoding workflows such as fixed versions, mode forcing, GS1/FNC1 payloads, structured payload helpers, and custom rendering.
- Documentation: docs.rs/qrcode-rs
- Crate page: crates.io/crates/qrcode-rs
- Repository: github.com/houseme/qrcode-rs
Highlights
- Encode standard QR Code and Micro QR Code symbols.
- Use simple constructors, an ergonomic builder API, or batch generation helpers.
- Render to terminal text, Unicode, ANSI, SVG, PNG, EPS, PIC, HTML, and PDF.
- Generate structured payloads for URLs, plain text, WiFi credentials, vCards, and GS1 data.
- Parse WiFi, vCard, and GS1 QR payloads back into typed data structures.
- Add accessible alt text and ARIA labels for SVG and HTML output.
- Opt into
serde, CLI support, async rendering, streaming, lightweight logging, andrqrr-based decoding via feature flags. - Use the 2.0 split crates directly when a library needs only core, render, parse, decode, or one backend layer.
- Run without default features for lean
no_std + allocusage.
Installation
Use the default feature set if you want the most common renderers enabled:
[]
= "2.0"
If you only need the core encoder and want to avoid the default rendering stack:
[]
= { = "2.0", = false }
Enable only the pieces you need:
[]
= { = "2.0", = false, = ["std", "svg", "serde"] }
Feature Flags
| Feature | Purpose |
|---|---|
default |
Enables std, image, svg, pic, eps, html, and pdf. |
std |
Links the standard library. Disable for no_std + alloc. |
image |
Raster image rendering, including PNG workflows. |
svg, pic, eps, html, pdf |
Individual renderer backends. |
serde |
Serialize / Deserialize support for core QR data types. |
log |
Emits encoder diagnostics through the log crate. |
async |
Enables Tokio-backed async rendering helpers. |
cli |
Builds the qrencodes command-line tool. |
decode-rqrr |
Enables decoding through rqrr. |
compat-1x |
Keeps the 1.x facade API available during the 2.0 migration. |
Workspace Crates
qrcode-rs remains the recommended facade for applications. The 2.0 release
also publishes smaller crates for libraries that need a narrower dependency
surface:
| Crate | Use it when you need |
|---|---|
qrcode-core |
Core encoding types, module views, traits, and plugin contracts. |
qrcode-render |
Shared render traits, text/Unicode/ANSI helpers, and color utilities. |
qrcode-image |
Image-backed pixels, PNG/JPEG encoding, logo overlays, and gradients. |
qrcode-parse |
WiFi, vCard, and GS1 payload parsing without the facade. |
qrcode-decode |
Decoder traits, grayscale views, Structured Append parsing, and the optional rqrr adapter. |
qrcode-svg, qrcode-eps, qrcode-pic, qrcode-html, qrcode-pdf |
Individual renderer backends. |
qrcode-cli |
Independently installable qrencodes command-line binary. |
For example:
[]
= "2.0"
= "2.0"
qrcode-compat is a workspace-local migration harness and is not published.
Quick Start
Render a PNG
use Luma;
use QrCode;
Generates:

Builder API with a fixed error-correction level
use ;
use unicode;
Generate a Micro QR SVG
use ;
use svg;
Preview:
Common Encoding Helpers
qrcode-rs includes convenience constructors for common payload types:
QrCode::for_url(...)QrCode::for_text(...)QrCode::for_wifi(ssid, password, auth)QrCode::for_vcard(name, phone, email)QrCode::for_gs1(...)QrCode::new_micro(...)QrCode::batch(inputs, ec_level)
Example:
use QrCode;
Structured Payload Parsing
The parse module can turn QR payload text back into typed domain objects:
use WifiConfig;
There are also parsers and examples for:
parse::vcard::VCardparse::gs1::Gs1Result
Accessible Output
For web and document workflows, the crate includes helpers to describe QR codes accessibly:
use QrCode;
use svg;
Decoding with rqrr
Enable decode-rqrr to bridge generated or external grayscale QR images back into data:
[]
= { = "2.0", = ["decode-rqrr"] }
use Luma;
use RqrrDecoder;
use ;
use QrCode;
Command-Line Tool
Enable the cli feature to build the bundled qrencodes binary:
Basic usage:
|
Supported output formats:
stringunicodeansisvgpngepspichtmlpdf
See the full help with:
More Examples
The examples/ directory covers the main workflows in this crate:
- Rendering:
encode_image,encode_svg,encode_html,encode_eps,encode_pic,encode_string - Advanced encoding:
encode_eci,encode_kanji,encode_fnc1,const_version,typed_encoding_mode,structured_append - Structured payloads:
parse_wifi,parse_vcard,parse_gs1,stream_codes - Plugins and async:
plugin_plain_text,plugin_invert_modules,async_render - Accessibility and styling:
accessible_svg,custom_colors,color_spaces,cmyk_print,batch_template,alt_text - Decoding and errors:
decode_roundtrip,error_handling - CLI patterns:
cli_tool
Migration
For the 1.x to 2.0 upgrade path, see MIGRATION-1.x-to-2.0.md. The compat-1x feature keeps the legacy facade available while call sites move to the builder, module-view, streaming, and split-crate APIs. Plugin authors can follow PLUGIN_GUIDE.md.
Supply-chain verification
The repository checks its locked dependency graph with cargo deny and
cargo vet in CI. The minimal feature is an explicit dependency-free
profile; SVG can be added without enabling raster/image dependencies:
Tagged releases include CycloneDX SBOM archives and Sigstore keyless signatures. Install cosign and verify an asset with the certificate emitted alongside it:
GitHub provenance attestations for crate assets can be verified with:
Security
See SECURITY.md for supported versions and the private vulnerability-reporting process. The repository runs a scheduled RustSec dependency advisory check; the badge above reflects that workflow, not a security certification. The encoder does not provide encryption or authentication, so applications must validate untrusted payloads and protect generated files and logs. The current verification boundary and deferred security gates are summarized in docs/security-audit.md.
License
Licensed under either of:
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contributing
See CONTRIBUTING.md for development and contribution guidelines, including the local property-test, differential-test, and fuzzing commands used by CI.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Acknowledgements
Thanks to Kennytm. This crate is based on qrcode-rust.