Barcode
Read barcodes and QR codes from images, identify their symbology, and generate new ones as PNGs
- Connector software
- Free and open source
- Service credentials
- Not needed
- Query Farm hosting
- Available · $10/month organization minimum
Use with an agent
Install the Orchard skill in your project to help your agent find connectors, configure them, and verify SQL results.
npx skills add Query-farm/vgi-skills --skill orchard
Copy this request into your coding agent to get started.
Use https://query.farm/products/orchard/connectors/barcode/index.md to help me query Barcode with DuckDB or Haybarn 2.0.1 and VGI protocol 3.4. Ask only for missing details about the result I need or whether I want local execution, self-hosting or Query Farm hosting. Check the connector's actual hosting availability, credentials and input requirements. Read one format of each needed reference and the exact object declarations before writing SQL. Use a released connector, and distinguish a saved example result from anything you actually execute. If you cannot run the query, tell me what remains to verify.
Fan one image out into every symbol it contains, one row each.
Example output · captured
- Connector release
- v0.5.0
- Engine
- 2.0.1
- VGI protocol
- 3.4.0
SELECT seq, format, text
FROM barcode.main.decode_barcodes(barcode.main.generate_qr('multi'))
ORDER BY seq
| seq | format | text |
|---|---|---|
| 0 | QR_CODE | multi |
Quick start
Choose where to run Barcode, then follow the steps below.
The connector runs alongside DuckDB or Haybarn. No Query Farm account is needed.
1. Install the vgi extension
Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.
SET allow_extension_repositories = 'allowed';
CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
WITH PREFIX 'https://duckdb-extensions.query.farm';
INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;
INSTALL vgi FROM community;
LOAD vgi;
2. Attach the connector
Attach the release directly
Downloads the latest release for your platform and caches it locally.
ATTACH 'barcode' AS barcode (
TYPE vgi,
LOCATION 'github-auto://Query-farm/vgi-barcode'
);
Attach the signed image
Needs Docker, Podman or another OCI runtime. The extension runs the container and talks to it over stdio.
ATTACH 'barcode' AS barcode (
TYPE vgi,
LOCATION 'oci://ghcr.io/query-farm/vgi-barcode:0.5.0'
);
3. Run a query
SELECT seq, format, text
FROM barcode.main.decode_barcodes(barcode.main.generate_qr('multi'))
ORDER BY seq
Run the connector on a server you manage. You operate the service and choose who can connect.
1. Deploy the connector on your server
Follow the connector’s deployment instructions. Use its supported HTTP transport, or launch it remotely over SSH. The connection guide explains both options.
2. Install the vgi extension
Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.
SET allow_extension_repositories = 'allowed';
CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
WITH PREFIX 'https://duckdb-extensions.query.farm';
INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;
INSTALL vgi FROM community;
LOAD vgi;
3. Attach the connector
For an HTTP deployment, replace the example URL with your endpoint. Add the authentication options your deployment requires. For SSH, use the SSH connection instructions.
ATTACH 'barcode' AS barcode
(TYPE vgi, LOCATION 'https://your-connector.example.com');
4. Run a query
SELECT seq, format, text
FROM barcode.main.decode_barcodes(barcode.main.generate_qr('multi'))
ORDER BY seq
Query Farm operates Barcode for your team. Hosting has a $10 monthly minimum per organization; usage counts toward it. From $2.97 per instance-month ($10 monthly minimum).
1. Create your hosted connector
Open the console, choose your organization and deployment size, and add any service credentials there.
2. Install the vgi extension
SET allow_extension_repositories = 'allowed';
CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
WITH PREFIX 'https://duckdb-extensions.query.farm';
INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;
INSTALL vgi FROM community;
LOAD vgi;
3. Attach your deployment
Copy the ATTACH statement from your deployment in the console and run it in DuckDB or Haybarn. Use barcode as the catalog alias for the query below.
4. Run a query
SELECT seq, format, text
FROM barcode.main.decode_barcodes(barcode.main.generate_qr('multi'))
ORDER BY seq
Technical details
- Verified connector release
- v0.5.0
- Engine
- 2.0.1
- VGI protocol
- 3.4.0
- Verified on
- December 1, 2026
Pin a version for production
When running the connector yourself, keep a specific release until you’re ready to upgrade. Replace the ATTACH statement above with this one and follow the same extension and credential setup.
Attach the release directly
Uses the verified release each time you attach the connector.
ATTACH 'barcode' AS barcode (
TYPE vgi,
LOCATION 'github-auto://Query-farm/[email protected]'
);
Attach the signed image
Needs Docker, Podman or another OCI runtime. The extension runs the container and talks to it over stdio.
ATTACH 'barcode' AS barcode (
TYPE vgi,
LOCATION 'oci://ghcr.io/query-farm/vgi-barcode:0.5.0'
);
Overview
Barcode and QR-code decoding and generation over Apache Arrow.

Read and write barcodes and QR codes directly in SQL: decode QR, EAN, UPC, Code 128, Code 39, Data Matrix, PDF417, Aztec and more out of image BLOBs, and generate scannable barcode PNGs from text — all over Apache Arrow, with no external service.
What it does and who it's for
The barcode extension turns DuckDB into a complete barcode and QR-code toolkit. Data engineers, retail and logistics teams, and anyone holding a column of product photos or scanned documents can pull the encoded text and symbology out of images, or mint fresh barcode/QR images for labels, tickets, and links — entirely in SQL. Decoding is hardened against hostile or oversized input: a corrupt, empty, or giant image yields NULL (scalars) or zero rows (tables) instead of crashing the worker, so it is safe to run across untrusted data at scale.
How it works
Decoding and encoding are powered by rxing, the maintained Rust port of the venerable ZXing ("zebra crossing") library. Input rasters (PNG, JPEG, GIF, BMP, WebP) are converted to grayscale and scanned for one or many symbols; text is encoded into a bit matrix and rendered to a PNG BLOB. Full API documentation for the underlying library lives at docs.rs/rxing. The worker streams everything over Apache Arrow IPC, so results flow back into DuckDB as native columns without intermediate files.
When to reach for it
Reach for this worker to read product or QR codes out of a column of images, to fan a single image that holds several codes into one row per symbol, or to produce scannable barcode and QR PNGs for labels, tickets, and links — without leaving SQL or standing up an external service. Text encoding and image decoding round-trip cleanly, so you can both mint and re-read codes in one query. A quick round-trip looks like:
SELECT decode_barcode(generate_qr('https://query.farm'));
SELECT generate_barcode('5901234123457', 'EAN_13');Catalog
Everything barcode exposes once attached — read straight from the worker's
released build.
main 1 table · 5 functions
Barcode / QR-code decode and generation functions.
Schema examples (9)
Round-trip: encode text as a QR image, then decode it back to a string.
SELECT barcode.main.decode_barcode(barcode.main.generate_qr('hello world')) AS decoded;
Detect the symbology of the first barcode/QR in a generated image.
SELECT barcode.main.barcode_format(barcode.main.generate_qr('hello world')) AS format;
Encode a URL as a QR-code PNG image (returns a BLOB).
SELECT barcode.main.generate_qr('https://query.farm') AS qr_png;
Encode an EAN-13 product code as a barcode PNG image.
SELECT barcode.main.generate_barcode('5901234123457', 'EAN_13') AS ean13_png;
5 more examples
List every supported symbology name, alphabetically.
SELECT format FROM barcode.main.barcode_formats ORDER BY format;
Fan one image out into every symbol it contains, one row each.
SELECT seq, format, text
FROM barcode.main.decode_barcodes(barcode.main.generate_qr('multi'))
ORDER BY seq;
| seq | format | text |
|---|---|---|
| 0 | QR_CODE | multi |
Label QA: print EAN-13 barcodes for a list of SKUs, scan each image back, and flag any that do not round-trip (a leading-zero EAN-13 reads back as its 12-digit UPC_A).
SELECT sku, barcode.main.barcode_format(png) AS format,
barcode.main.decode_barcode(png) AS decoded,
barcode.main.decode_barcode(png) = sku AS round_trips
FROM (SELECT sku, barcode.main.generate_barcode(sku, 'EAN_13') AS png FROM (VALUES ('5901234123457'), ('4006381333931'), ('0036000291452')) AS t(sku))
ORDER BY sku;
Relabel a product: read the code off its EAN-13 barcode, encode a product-page URL built from it as a QR code, and decode every symbol in the new QR image to verify it.
SELECT seq, format, text
FROM barcode.main.decode_barcodes(barcode.main.generate_qr('https://shop.example/p/' || barcode.main.decode_barcode(barcode.main.generate_barcode('4006381333931', 'EAN_13'))))
ORDER BY seq;
Symbology coverage: detect the format of each image in a label set and count labels per supported symbology, listing unused symbologies with 0.
WITH labels AS (SELECT barcode.main.generate_qr(t.ticket) AS png FROM (VALUES ('ticket-001'), ('ticket-002')) AS t(ticket) UNION ALL SELECT barcode.main.generate_barcode('5901234123457', 'EAN_13') UNION ALL SELECT barcode.main.generate_barcode('PALLET-77', 'CODE_128')) SELECT f.format, count(l.png) AS labels
FROM barcode.main.barcode_formats AS f
LEFT JOIN labels AS l ON barcode.main.barcode_format(l.png) = f.format
GROUP BY f.format
ORDER BY labels DESC, f.format;
barcode_formats
Supported barcode/QR symbology names, one per row.
Count how many barcode/QR symbologies this worker supports.
SELECT count(*) AS supported_formats FROM barcode.main.barcode_formats;
List the Code-family symbologies (CODE_39/93/128) alphabetically.
SELECT format
FROM barcode.main.barcode_formats
WHERE format LIKE 'CODE%'
ORDER BY format;
Symbology coverage: detect the format of each image in a label set and count labels per supported symbology, listing unused symbologies with 0.
WITH labels AS (SELECT barcode.main.generate_qr(t.ticket) AS png FROM (VALUES ('ticket-001'), ('ticket-002')) AS t(ticket) UNION ALL SELECT barcode.main.generate_barcode('5901234123457', 'EAN_13') UNION ALL SELECT barcode.main.generate_barcode('PALLET-77', 'CODE_128')) SELECT f.format, count(l.png) AS labels
FROM barcode.main.barcode_formats AS f
LEFT JOIN labels AS l ON barcode.main.barcode_format(l.png) = f.format
GROUP BY f.format
ORDER BY labels DESC, f.format;
barcode_format (blob BLOB)
Format name of the first barcode/QR in an image BLOB, e.g. QR_CODE (NULL if none)
Identify the symbology of the first barcode/QR in an image (e.g. 'QR_CODE').
SELECT barcode.main.barcode_format(barcode.main.generate_qr('hello world'));
decode_barcode (blob BLOB)
Decode the first barcode/QR in an image BLOB to its text (NULL if none)
Decode the text of the first barcode/QR in an image (here a freshly generated QR).
SELECT barcode.main.decode_barcode(barcode.main.generate_qr('hello world'));
generate_barcode (text VARCHAR, format ANY, size_px ANY) +1 overload
Generate a barcode PNG (BLOB) for the given text in a named symbology at the default size
generate_barcode(text VARCHAR, format ANY) → BLOBgenerate_barcode(text VARCHAR, format ANY, size_px ANY) → BLOB
Encode text as a default-size Code 128 barcode PNG.
SELECT barcode.main.generate_barcode('CODE128', 'CODE_128');
Encode an EAN-13 product code as a 600-pixel-wide barcode PNG.
SELECT barcode.main.generate_barcode('5901234123457', 'EAN_13', 600);
Label QA: print EAN-13 barcodes for a list of SKUs, scan each image back, and flag any that do not round-trip (a leading-zero EAN-13 reads back as its 12-digit UPC_A).
SELECT sku, barcode.main.barcode_format(png) AS format,
barcode.main.decode_barcode(png) AS decoded,
barcode.main.decode_barcode(png) = sku AS round_trips
FROM (SELECT sku, barcode.main.generate_barcode(sku, 'EAN_13') AS png FROM (VALUES ('5901234123457'), ('4006381333931'), ('0036000291452')) AS t(sku))
ORDER BY sku;
generate_qr (text VARCHAR, size_px ANY) +1 overload
Generate a QR-code PNG (BLOB) for the given text at the default size
generate_qr(text VARCHAR) → BLOBgenerate_qr(text VARCHAR, size_px ANY) → BLOB
Encode a URL as a default-size QR-code PNG.
SELECT barcode.main.generate_qr('https://query.farm');
Encode a URL as a 512x512-pixel QR-code PNG.
SELECT barcode.main.generate_qr('https://query.farm', 512);
decode_barcodes (blob BLOB)
Decode ALL barcodes/QR codes in an image BLOB into (seq, format, text) rows
Relabel a product: read the code off its EAN-13 barcode, encode a product-page URL built from it as a QR code, and decode every symbol in the new QR image to verify it.
SELECT seq, format, text
FROM barcode.main.decode_barcodes(barcode.main.generate_qr('https://shop.example/p/' || barcode.main.decode_barcode(barcode.main.generate_barcode('4006381333931', 'EAN_13'))))
ORDER BY seq;
Decode every symbol in a freshly generated QR image.
SELECT seq, format, text
FROM barcode.main.decode_barcodes(barcode.main.generate_qr('hello world'))
ORDER BY seq;
SELECT format, text
FROM barcode.main.decode_barcodes(barcode.main.generate_barcode('5901234123457', 'EAN_13'));
Try these queries
Round-trip: encode text as a QR image, then decode it back to a string.
SELECT barcode.main.decode_barcode(barcode.main.generate_qr('hello world')) AS decoded
Detect the symbology of the first barcode/QR in a generated image.
SELECT barcode.main.barcode_format(barcode.main.generate_qr('hello world')) AS format
Encode a URL as a QR-code PNG image (returns a BLOB).
SELECT barcode.main.generate_qr('https://query.farm') AS qr_png
Uses generate_qr
Encode an EAN-13 product code as a barcode PNG image.
SELECT barcode.main.generate_barcode('5901234123457', 'EAN_13') AS ean13_png
Uses generate_barcode
List every supported symbology name, alphabetically.
SELECT format FROM barcode.main.barcode_formats ORDER BY format
Uses barcode_formats
Relabel a product: read the code off its EAN-13 barcode, encode a product-page URL built from it as a QR code, and decode every symbol in the new QR image to verify it.
SELECT seq, format, text
FROM barcode.main.decode_barcodes(barcode.main.generate_qr('https://shop.example/p/' || barcode.main.decode_barcode(barcode.main.generate_barcode('4006381333931', 'EAN_13'))))
ORDER BY seq
Uses decode_barcodesgenerate_qrdecode_barcodegenerate_barcode
12 more examples in the Catalog, each listed under the table or function it uses.
Barcode is an independent open-source connector from Query.Farm. It is not affiliated with, endorsed by or sponsored by the services, projects or organisations it works with. Product names, logos and trademarks belong to their respective owners.
Related workers
Image
Documents & media
Decode images, read EXIF and GPS tags, spot near-duplicates by perceptual hash, and make thumbnails
Chart
Documents & media
Render query results as line, bar, pie, scatter, and histogram PNG charts with JFreeChart
Documents & media
Pull tables, words with their positions, page geometry, form fields and metadata out of PDFs, and render pages to PNG