Skip to content

@qrcodesdk/core

@qrcodesdk/core generates QR matrices, SVG strings, and terminal text. It needs no browser or Node.js APIs. Custom renderers can turn its matrices into other formats.

Terminal window
npm install @qrcodesdk/core
import {QRCodeSVGRenderer, qrcode} from '@qrcodesdk/core';
const svg = qrcode('https://qrcodesdk.dev').render(QRCodeSVGRenderer());

The result is an SVG string. See the SVG renderer for its options.

Capability API Return type
Generate a QR matrix qrcode(payload).matrix() QRCodeMatrix
Render scalable vector output QRCodeSVGRenderer SVG string
Render terminal output QRCodeTextRenderer text string

See Builder and matrix for payloads, matrix options, and builder methods.

Import shape and pattern factories from @qrcodesdk/core/style:

import {QRCodeSVGRenderer, qrcode} from '@qrcodesdk/core';
import {circle, finder, rounded} from '@qrcodesdk/core/style';
const svg = qrcode('https://qrcodesdk.dev').render(
QRCodeSVGRenderer({
style: {
moduleSize: 8,
foreground: '#0f172a',
modules: rounded(),
finder: finder({ring: rounded({radius: 1}), center: circle(), color: '#e11d48'}),
},
}),
);

See Customize appearance for every style option and custom shapes.

Typed payload helpers turn contact, calendar, email, phone, SMS, geographic, and Wi-Fi data into payload strings. Import them from @qrcodesdk/core/payload. The React, React Native, Vue, Svelte, and Angular packages re-export them.

Core runs in any JavaScript runtime with native ESM, ES2020, and a global TextEncoder. Payload URL fields also require the standard URL API. It has no Node.js, DOM, filesystem, or framework dependency.

Runtime Support policy
Node.js 22.0.0 or newer; tested on 22, 24, and 26
Deno Current stable major
Bun Current stable release
Browsers Current evergreen browser families
Other runtimes and edge workers Native ESM, ES2020, and a global TextEncoder required

Module format:

  • The package is ES modules only. CommonJS code needs Node.js 22.12 or newer for require(), or a dynamic import(). See Module format.
  • TypeScript projects need moduleResolution: 'bundler', 'node16', or 'nodenext' to resolve the package’s entry points and subpaths.

Add a runtime or framework package for other outputs:

Package Use it for Return value
@qrcodesdk/browser Canvas element, PNG, WebP, GIF, and JPEG Image elements, browser downloads HTMLCanvasElement, HTMLImageElement, void
@qrcodesdk/node PNG, WebP, GIF, and JPEG bytes Buffer
@qrcodesdk/cli Command line generation from terminals and scripts Terminal text, SVG, PNG, WebP, GIF, and JPEG files
@qrcodesdk/react React SVG, PNG, WebP, GIF, JPEG, and Canvas components React element
@qrcodesdk/react-native React Native SVG, PNG, WebP, GIF, and JPEG components React Native element
@qrcodesdk/vue Vue SVG, PNG, WebP, GIF, JPEG, and Canvas components Vue component
@qrcodesdk/svelte Svelte SVG, PNG, WebP, GIF, JPEG, and Canvas components Svelte component
@qrcodesdk/angular Angular SVG, PNG, WebP, GIF, JPEG, and Canvas components Angular component

Compare every built-in output in Renderer outputs.

Entry point Contains
@qrcodesdk/core The builder, SVG and text renderers, errors, and shared types
@qrcodesdk/core/matrix The builder, matrix types, and module role names
@qrcodesdk/core/svg The SVG renderer and svgCenterImage()
@qrcodesdk/core/text The terminal text renderer
@qrcodesdk/core/error QRCodeError and its codes
@qrcodesdk/core/style Shape and pattern factories and custom path types
@qrcodesdk/core/payload Payload helpers
@qrcodesdk/core/segmenter The optional mixed-mode optimizer, available only from this path
@qrcodesdk/core/kanji The optional Kanji mode table, available only from this path
@qrcodesdk/core/micro microQR() for Micro QR codes, available only from this path
@qrcodesdk/core/rmqr rMQR() for rMQR codes, available only from this path

Bundlers with tree shaking drop the parts you do not use. Without tree shaking, for example directly in Node.js, import from a subpath to avoid loading unrelated renderers.

import {
type QRCodeDataImageURL,
QRCodeError,
type QRCodeErrorCode,
type QRCodeErrorOptions,
type QRCodeSVGAccessibilityOptions,
type QRCodeSVGCenterImage,
type QRCodeSVGCenterImageLayout,
type QRCodeSVGOptions,
QRCodeSVGRenderer,
type QRCodeSVGRendererOptions,
type QRCodeTextANSIBackgroundOptions,
type QRCodeTextANSIOptions,
QRCodeTextRenderer,
type QRCodeTextRendererOptions,
type QRCodeTextStyle,
QR_CODE_ERROR_CODES,
svgCenterImage,
} from '@qrcodesdk/core';
import {kanji} from '@qrcodesdk/core/kanji';
import {
QRCodeBuilder,
type QRCodeEncodingMode,
type QRCodeErrorCorrectionLevel,
type QRCodeKanji,
type QRCodeMask,
type QRCodeMatrix,
type QRCodeMatrixOptions,
type QRCodeMode,
type QRCodeModuleRole,
type QRCodePayload,
type QRCodeRenderer,
type QRCodeSegment,
type QRCodeSegmenter,
type QRCodeSegmenterOptions,
type QRCodeStandardMatrixOptions,
type QRCodeSymbol,
type QRCodeSymbolMatrixOptions,
type QRCodeVersion,
QR_CODE_MODULE_ROLES,
qrcode,
} from '@qrcodesdk/core/matrix';
import {
type QRCodeMicroMask,
type QRCodeMicroOptions,
type QRCodeMicroVersion,
microQR,
} from '@qrcodesdk/core/micro';
import {
type QRCodeCalendarPayload,
type QRCodeEmailPayload,
type QRCodeGeoPayload,
type QRCodePhonePayload,
type QRCodeSMSPayload,
type QRCodeVCardAddress,
type QRCodeVCardEmail,
type QRCodeVCardName,
type QRCodeVCardPayload,
type QRCodeVCardPhone,
type QRCodeWiFiEncryption,
type QRCodeWiFiPayload,
calendarPayload,
emailPayload,
geoPayload,
phonePayload,
smsPayload,
vcardPayload,
wifiPayload,
} from '@qrcodesdk/core/payload';
import {
type QRCodeRMQRHeight,
type QRCodeRMQROptions,
type QRCodeRMQRVersion,
rMQR,
} from '@qrcodesdk/core/rmqr';
import {automaticSegmenter} from '@qrcodesdk/core/segmenter';
import {
type QRCodeAlignmentCenterShape,
type QRCodeAlignmentOptions,
type QRCodeAlignmentRingShape,
type QRCodeAlignmentStyle,
type QRCodeCenterImageLayout,
type QRCodeCircleShapeOptions,
type QRCodeColor,
type QRCodeFinderCenterShape,
type QRCodeFinderOptions,
type QRCodeFinderRingShape,
type QRCodeFinderStyle,
type QRCodeModulePattern,
type QRCodeModuleShape,
type QRCodeRoundedShapeOptions,
type QRCodeShape,
type QRCodeShapePath,
type QRCodeShapePiece,
type QRCodeVisualStyle,
alignment,
circle,
customShape,
diagonal,
finder,
rounded,
} from '@qrcodesdk/core/style';

Output is deterministic for one installed version. Matrix modules, SVG markup, and PNG, WebP, GIF, and JPEG bytes may change between releases. When exact output matters, pin exact package versions and keep fixtures. See the version and output policy.

By default, auto mode picks one encoding mode for the whole payload. Import the optimizer to mix modes when that makes the QR code smaller:

import {qrcode} from '@qrcodesdk/core';
import {automaticSegmenter} from '@qrcodesdk/core/segmenter';
qrcode('ABCD12345678901234567890abcd').mode('auto').segmenter(automaticSegmenter).matrix();
  • mode: 'auto' works with or without the segmenter.
  • Concrete modes, such as 'octet', bypass it.

See Builder and matrix for the callback contract and version selection.

Kanji mode encodes Japanese text in 13 bits per character instead of UTF-8 bytes. Its Shift JIS table adds about 13 kB gzipped, so it is opt-in:

import {qrcode} from '@qrcodesdk/core';
import {kanji} from '@qrcodesdk/core/kanji';
import {automaticSegmenter} from '@qrcodesdk/core/segmenter';
qrcode('漢字テスト').kanji(kanji).matrix();
qrcode('東京タワー 333m').segmenter(automaticSegmenter).kanji(kanji).matrix();

See Kanji mode for the covered characters and scanner support.

@qrcodesdk/core

Version
v0.0.6
Downloads
1.5K/mo
Install size
693.0 kB
Bundled size
8.3 kB
Works with
Works with Google ChromeWorks with FirefoxWorks with Safari
Works with Node.jsWorks with BunWorks with Deno

Support QRCodeSDK

If you find QRCodeSDK useful, please consider sponsoring the project!