Skip to main content

convertlib 3.8.0 copy "convertlib: ^3.8.0" to clipboard
convertlib: ^3.8.0 copied to clipboard

Fast, zero-dependency codecs for Base2/8/16/32/36/45/58/62/64/85, Bech32, Punycode, percent (URL), quoted-printable, BigInt, UTF-8, and the PHC/crypt format.

convertlib

Fast, error-resilient, zero-dependency codecs for Dart.

Binary · Octal · Hex · Base-32 · Base-36 · Base-45 · Base-58 · Base-62 · Base-64 · Base-85 · Bech32 · Punycode · IMAP UTF‑7 · Multibase · Percent / URL · Quoted‑Printable · BigInt · UTF-8 / 16 / 32 · PHC / Modular Crypt

package version dart support likes pub points codecov test

A pure-Dart library of fast, error-resilient codecs: binary, octal, hex, Base-32, Base-36, Base-45, Base-58, Base-62, Base-64, Base-85, Bech32, Punycode, IMAP UTF-7, multibase, percent (URL) encoding, quoted-printable, BigInt, UTF-8, UTF-16, UTF-32, and the PHC / Modular Crypt Format — with a rich set of alphabet variants, optional padding, and zero dependencies.

convertlib is the foundation layer of a three-package family:

convertlib → hashlib → cipherlib

Both hashlib (hashes, MACs, KDFs) and cipherlib (ciphers, AEAD, ML-KEM) build on it, reusing its codecs to render digests, keys, and ciphertext as text. It carries no runtime dependencies of its own.

✨ Highlights #

Feature What you get
🌍 Runs on every platform Pure Dart with no native code or FFI — the same library works on the VM, Flutter (Android, iOS, Windows, macOS, Linux), and the web (dart2js and dart2wasm).
📦 Zero dependencies Nothing is pulled into your dependency tree.
🔡 Broad coverage Base-2, Base-8, Base-16, Base-32, Base-36, Base-45, Base-58, Base-62, Base-64, Base-85, Bech32, Punycode, IMAP UTF-7, multibase, percent (URL) encoding, quoted-printable, BigInt, UTF-8, UTF-16, UTF-32, and the PHC / Modular Crypt Format, each with a symmetrical to/from pair.
🎛️ Many alphabet variants RFC 4648 standard, base32hex, Crockford, z-base-32, geohash, word-safe, URL/filename-safe Base-64, bcrypt, IMAP, and line-wrapped MIME and PEM.
✳️ Optional padding Encode and decode with or without = padding.
🛡️ Error resilient Decoders accept case and alphabet variations where the encoding allows it, and raise typed errors on genuinely invalid input.
🧩 Convenient output Results integrate with ByteCollector, the digest container shared with hashlib, for one-call re-encoding.
⚙️ Bytes or strings, throwing or not Every encoder has a to<Name>Bytes twin returning a Uint8List, every decoder a non-throwing tryFrom<Name> returning null, plus a top-level constantTimeEquals.

📦 Install #

dependencies:
  convertlib: ^3.8.0

or run dart pub add convertlib. A single import exposes every codec:

import 'package:convertlib/convertlib.dart';

Full API reference: convertlib library.

⚡ Quickstart #

Every codec exposes a to<Name> encoder and a from<Name> decoder that are exact inverses of each other:

import 'package:convertlib/convertlib.dart';

void main() {
  final data = toUtf8('convertlib');

  // Encode the same bytes in a few common ways
  final hex = toHex(data);
  final b64 = toBase64(data);
  final b32 = toBase32(data);

  print('bytes  : $data');
  print('hex    : $hex');
  print('base64 : $b64');
  print('base32 : $b32');

  // Every encoder has an exact inverse
  print('decoded: ${fromUtf8(fromHex(hex))}');
  print('match  : ${fromUtf8(fromBase64(b64)) == 'convertlib'}');
}

Every snippet in this README is also a runnable program in the example folder.

🧬 Supported codecs #

Encoding Class Encode Decode Source
Binary (Base-2) Base2Codec toBinary, toBinaryBytes fromBinary, tryFromBinary —
Octal (Base-8) Base8Codec toOctal, toOctalBytes fromOctal, tryFromOctal —
Hexadecimal (Base-16) Base16Codec toHex, toHexBytes fromHex, tryFromHex RFC-4648
Base-32 Base32Codec toBase32, toBase32Bytes fromBase32, tryFromBase32 RFC-4648
Base-36 Base36Codec toBase36, toBase36Bytes fromBase36, tryFromBase36 —
Base-45 Base45Codec toBase45, toBase45Bytes fromBase45, tryFromBase45 RFC-9285
Base-58 Base58Codec toBase58, toBase58Bytes fromBase58, tryFromBase58 Draft
Base-62 Base62Codec toBase62, toBase62Bytes fromBase62, tryFromBase62 —
Base-64 Base64Codec toBase64, toBase64Bytes fromBase64, tryFromBase64 RFC-4648
Base-85 Base85Codec toBase85, toBase85Bytes fromBase85, tryFromBase85 Ascii85, Z85
Bech32 Bech32Codec toBech32 fromBech32, tryFromBech32 BIP-173, BIP-350
SegWit address SegwitCodec toSegwitAddress fromSegwitAddress, tryFromSegwitAddress BIP-173, BIP-350
Punycode PunycodeCodec toPunycode fromPunycode, tryFromPunycode RFC-3492, RFC-3490
IMAP UTF-7 ImapUtf7Codec toImapUtf7 fromImapUtf7, tryFromImapUtf7 RFC-3501
Multibase Multibase toMultibase fromMultibase, tryFromMultibase Multibase
Percent (URL) PercentCodec toPercent, toPercentBytes fromPercent, tryFromPercent RFC-3986
Quoted-Printable QuotedPrintableCodec toQuotedPrintable, toQuotedPrintableBytes fromQuotedPrintable, tryFromQuotedPrintable RFC-2045, RFC-2047
BigInt BigIntCodec toBigInt fromBigInt, tryFromBigInt —
UTF-8 UTF8Codec toUtf8 fromUtf8, tryFromUtf8 RFC-3629
UTF-16 UTF16Codec toUtf16 fromUtf16, tryFromUtf16 RFC-2781
UTF-32 UTF32Codec toUtf32 fromUtf32, tryFromUtf32 Unicode §3.9
Modular Crypt Format CryptFormat toCrypt fromCrypt PHC string format

🔤 Variants #

Each codec ships its variants as static const instances. Pick one with the flags of to<Name>/from<Name>, or pass any instance as codec:. The API reference documents the exact behavior of each.

Alphabets (the default is listed first):

Variant Flag Alphabet
Base16Codec.lower 0123456789abcdef
Base16Codec.upper upper: true 0123456789ABCDEF
Base32Codec.standard ABCDEFGHIJKLMNOPQRSTUVWXYZ234567
Base32Codec.lowercase lower: true abcdefghijklmnopqrstuvwxyz234567
Base32Codec.hex 0123456789ABCDEFGHIJKLMNOPQRSTUV
Base32Codec.hexLower 0123456789abcdefghijklmnopqrstuv
Base32Codec.crockford 0123456789ABCDEFGHJKMNPQRSTVWXYZ
Base32Codec.geohash 0123456789bcdefghjkmnpqrstuvwxyz
Base32Codec.z ybndrfg8ejkmcpqxot1uwisza345h769
Base32Codec.wordSafe 23456789CFGHJMPQRVWXcfghjmpqrvwx
Base36Codec.standard 0123456789abcdefghijklmnopqrstuvwxyz
Base36Codec.upper upper: true 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ
Base45Codec.standard 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./: (with a space)
Base58Codec.standard 123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz (Bitcoin)
Base58Codec.flickr 123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ
Base58Codec.ripple rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz
Base62Codec.standard 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
Base62Codec.lowerFirst lowerFirst: true 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
Base64Codec.standard A-Za-z0-9+/
Base64Codec.urlSafe url: true A-Za-z0-9-_
Base64Codec.bcrypt ./A-Za-z0-9
Base64Codec.imap A-Za-z0-9+,
Base85Codec.standard ! to u (Ascii85; z for a zero group)
Base85Codec.z85 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-:+=^!/*?&<>()[]{}@%$#
Base85Codec.git 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$%&()*+-;<=>?@^_`{|}~

Base-32 and Base-64 take padding: to add or drop =. Base-36, Base-58 and Base-62 read the input as one number, writing each leading zero byte as the first character of the alphabet. Crockford decodes I/L as 1 and O as 0.

Formats (the default is listed first):

Codec Variants Flags
Base64Codec mime (76 columns, CRLF), pem (64 columns, LF), wrapped(lineLength, lineSeparator: ...)
Base85Codec ipv6 (RFC 1924: 16 bytes as one 20-character number)
Bech32Codec bech32 (BIP-173), bech32m (BIP-350), lightning (no length limit) m: true
PunycodeCodec standard (bücher ⇄ bcher-kva), domain (münchen.de ⇄ xn--mnchen-3ya.de) domain: true
ImapUtf7Codec standard (strict decoding), lenient lenient: true
PercentCodec standard (RFC 3986), component (encodeURIComponent), form (space as +), custom(...) component: true, form: true
QuotedPrintableCodec standard (text), binary (escapes CRLF too), header (RFC 2047 "Q") binary: true, header: true
BigIntCodec lsbFirst, msbFirst msbFirst: true
UTF8Codec standard (throws), lenient (U+FFFD) allowMalformed: true
UTF16Codec, UTF32Codec bigEndian, littleEndian, standard (byte order mark), or any combination as a const constructor littleEndian:, bom:, allowMalformed:
Multibase every encoding of the multibase table except proquint and base256emoji; the prefix names it, so fromMultibase takes no other argument

🧰 Bytes, non-throwing decode, and constant-time compare #

  • Byte output — the to<Name>Bytes encoders in the table above return the encoded ASCII as a Uint8List, skipping the intermediate String.
  • Non-throwing decoders — the tryFrom<Name> decoders return null instead of throwing a FormatException on invalid input.
  • Constant-time compare — constantTimeEquals(a, b) compares two byte lists without exiting early on the first mismatch, for verifying MACs and digests.
  • Streaming — encoders and decoders support chunked conversion, so encoder.bind(stream) converts a stream as it arrives, with the same output as converting it whole. See Streaming for the exceptions.
  • Low-level building blocks — the generic converters BitEncoder/ BitDecoder, ByteEncoder/ByteDecoder, and AlphabetEncoder/ AlphabetDecoder are exported for building custom codecs.

📥 ByteCollector #

ByteCollector is the byte container shared with hashlib, holding the output of a hash or encoding function and re-encoding it on demand:

Method / getter Description
bytes Raw bytes as Uint8List
length Number of bytes
buffer The backing ByteBuffer
hex([upper]) Hexadecimal string (optionally uppercase)
binary() / octal() Binary / octal string representation
base32({upper, padding, codec}) Base-32 encoding, in any Base32Codec alphabet
base64({urlSafe, padding, codec}) Base-64 encoding, in any Base64Codec alphabet
base36({upper}) Base-36 encoding
base45() Base-45 encoding (RFC 9285)
base58({codec}) Base-58 encoding (Bitcoin alphabet default)
base62({lowerFirst}) Base-62 encoding
base85({codec}) Base-85 encoding (Ascii85 default)
bech32(hrp, {m, codec}) Bech32 / Bech32m string with the human-readable hrp
multibase([base]) Multibase text (base58btc default, as an IPFS CID)
bigInt({endian}) Interprets the bytes as a BigInt (big endian default)
number([bitLength, endian]) Reads an unsigned integer of the given bit-length
ascii() / utf8() Decodes bytes as ASCII / UTF-8 (allowMalformed)
utf16() / utf32() Decodes bytes as UTF-16 / UTF-32 (endian, BOM)
to(encoding) Decodes bytes with a given dart:convert Encoding
isEqual(other) Constant-time compare against bytes, buffer, or hex text

🍳 Recipes #

Base-32 alphabet variants #

The same bytes, rendered in each supported Base-32 alphabet — useful for human-friendly identifiers (Crockford), URLs (z-base-32), or geospatial codes (geohash):

import 'package:convertlib/convertlib.dart';

void main() {
  final data = toUtf8('Hello, convertlib!');

  print('standard   : ${toBase32(data)}');
  print('lowercase  : ${toBase32(data, lower: true)}');
  print('no padding : ${toBase32(data, padding: false)}');
  print('base32hex  : ${toBase32(data, codec: Base32Codec.hex)}');
  print('crockford  : ${toBase32(data, codec: Base32Codec.crockford)}');
  print('z-base-32  : ${toBase32(data, codec: Base32Codec.z)}');
  print('geohash    : ${toBase32(data, codec: Base32Codec.geohash)}');
  print('word-safe  : ${toBase32(data, codec: Base32Codec.wordSafe)}');

  // Decoding is the exact inverse of encoding
  final back = fromBase32(toBase32(data));
  print('roundtrip  : ${fromUtf8(back)}');
}

URL-safe and unpadded Base-64 #

For tokens embedded in URLs or JSON, drop the padding and switch to the URL/filename-safe alphabet:

import 'package:convertlib/convertlib.dart';

void main() {
  final data = toUtf8('a >> b, c/d');

  print('standard    : ${toBase64(data)}');
  print('url-safe    : ${toBase64(data, url: true)}');
  print('no padding  : ${toBase64(data, url: true, padding: false)}');
  print('bcrypt      : ${toBase64(data, codec: Base64Codec.bcrypt)}');
  print('imap        : ${toBase64(data, codec: Base64Codec.imap)}');

  // MIME wraps lines at 76 columns with CRLF, PEM at 64 with LF, and both
  // skip line breaks and other characters outside the alphabet when decoding.
  final pem = toBase64(List.filled(60, 0xff), codec: Base64Codec.pem);
  print('pem         :\n$pem');
  final mime = fromBase64('YSA+PiBi\r\nLCBjL2Q=', codec: Base64Codec.mime);
  print('mime decode : ${fromUtf8(mime)}');

  // Decode back to the original bytes
  final back = fromBase64(toBase64(data, url: true));
  print('roundtrip   : ${fromUtf8(back)}');
}

BigInt ↔ bytes #

Read a byte sequence as an arbitrary-precision integer and back. Combine with BigInt.toRadixString for a decimal (or any-base) string representation:

import 'package:convertlib/convertlib.dart';

void main() {
  var input = [0x3, 0xF1];
  print("input => $input");
  var encoded = toBigInt(input).toRadixString(10);
  print("to decimal => $encoded");
  var decoded = fromBigInt(BigInt.parse(encoded, radix: 10));
  print("from decimal => $decoded");
}

Streaming #

Every encoder and decoder is a Converter, so bind converts a stream chunk by chunk:

import 'dart:io';

import 'package:convertlib/convertlib.dart';

Future<void> main() async {
  // Encode a file to Base-64 without reading it into memory at once.
  final out = File('photo.b64').openWrite();
  await out.addStream(
    Base64Codec.standard.encoder
        .bind(File('photo.jpg').openRead())
        .cast<List<int>>(),
  );
  await out.close();

  // Decode UTF-8 as it arrives; a character split between chunks is kept
  // until the rest of it arrives.
  final text = await UTF8Codec.standard.decoder
      .bind(Stream.fromIterable([
        [0x68, 0xE2, 0x82],
        [0xAC]
      ]))
      .map(String.fromCharCodes)
      .join();
  print(text); // h€
}

The output is the same as converting the whole input at once, with three exceptions:

  • Base-36, Base-58, Base-62, and the IPv6 form of Base-85 read the whole input as one number, so their startChunkedConversion throws an UnsupportedError.
  • Hex and binary put a partial group first (fromHex('abc') is [0x0a, 0xbc]), so a stream throws a FormatException if it ends with an odd number of hex digits, or a number of binary digits that is not a multiple of 8.
  • Octal also groups from the end, so it converts the whole stream when it closes.

PHC / Modular Crypt Format #

Build and parse password-hash strings such as $argon2id$v=19$m=65536,t=3,p=4$...$.... The builder Base-64 encodes salt and hash bytes for you, and fromCrypt gives the fields back as typed accessors:

import 'package:convertlib/convertlib.dart';

void main() {
  // Build a PHC / Modular Crypt Format string from its parts.
  // `saltBytes` and `hashBytes` are Base-64 encoded (no padding) for you.
  final data = CryptData.builder('argon2id')
      .version('19')
      .param('m', 65536)
      .param('t', 3)
      .param('p', 4)
      .saltBytes(toUtf8('a-16-byte-salt!!'))
      .hashBytes(List.generate(32, (i) => i))
      .build();

  final encoded = toCrypt(data);
  print('encoded : $encoded');

  // Parse the string back into its structured fields.
  final parsed = fromCrypt(encoded);
  print('id      : ${parsed.id}');
  print('version : ${parsed.versionInt()}');
  print('m,t,p   : ${parsed.getIntParam('m')}, '
      '${parsed.getIntParam('t')}, ${parsed.getIntParam('p')}');
  print('salt    : ${fromUtf8(parsed.saltBytes()!)}');
  print('hash    : ${toHex(parsed.hashBytes()!)}');
}

🧪 Testing and reliability #

Codecs are trivial to get subtly wrong. It is not enough to check just the decode(encode(x)) == x round-trips alone. For example: a dropped bit mask can produce output that still passes round-trips cleanly. This package is tested against that failure mode directly:

  • Expectations come from outside the code. Every codec is checked against official vectors (RFC 4648 "foobar", RFC 3629 UTF-8 boundaries, PHC / bcrypt strings) and differentially against independent reference implementations: dart:convert, base_codecs, and base32, so a consistently-wrong codec cannot hide behind a passing round-trip.
  • Wide input coverage.
    • Randomized round-trips at every length from 0 to 99 for each alphabet variant
    • Full-range Unicode code points and surrogate-pair handling for UTF-8
    • Per-instance assertions of the exact alphabet string each codec emits, which catch miscopied lookup tables.
  • Failure paths are asserted, not assumed. Malformed UTF-8, invalid characters, and exhaustive invalid-length sweeps all verify that a typed error is raised (with the exact message and offset), never a silent wrong result.
  • Every platform. The suite runs on the Dart VM, Node.js (JavaScript), and Chrome (WASM) in CI across Dart SDK 2.19 and stable on Linux, macOS, and Windows. Special care has been given for the web, where integers behave differently.
  • Regressions stay fixed. Real bugs found in the past (a word-safe Base-32 table accidentally copied from z-base-32, a dropped & 0x3F mask in the UTF-8 decoder, a ByteCollector.isEqual self-comparison) each have a permanent, externally-anchored regression test, and a differential fuzz harness re-checks the codecs against the reference implementations.

Because correctness is anchored to independent references rather than the package's own agreement with itself, convertlib is safe to rely on in production. If you do hit a discrepancy, please open an issue and include your input and the expected output.

🚀 Benchmarks #

Libraries #

UTF-8 throughput is measured per source code point, not per byte. Crypt throughput is measured per character of the hash string. Base-36, Base-58 and Base-62 are quadratic in the input size, so they are measured only up to 1KB; larger cells are left empty.

Encoding #

Codec Library 1MB message 1KB message 32B message
Base-2 convertlib ████████████████
1.27 Gbps 🌟
████████████████
1.15 Gbps 🌟
████████████████
1.42 Gbps 🌟
Base-8 convertlib ████████████████
2.97 Gbps 🌟
████████████████
4.04 Gbps 🌟
████████████████
3.05 Gbps 🌟
Base-16 convertlib ████████████████
3.83 Gbps 🌟
████████████████
4.58 Gbps 🌟
████████████████
3.53 Gbps 🌟
base_codecs █░░░░░░░░░░░░░░░
173 Mbps 🔻22.14x
█░░░░░░░░░░░░░░░
160 Mbps 🔻28.59x
█░░░░░░░░░░░░░░░
154 Mbps 🔻22.92x
convert ██████████████░░
3.3 Gbps 🔻1.16x
██████████████░░
4.03 Gbps 🔻1.14x
██████████████░░
3.08 Gbps 🔻1.15x
hex █░░░░░░░░░░░░░░░
136 Mbps 🔻28.16x
█░░░░░░░░░░░░░░░
128 Mbps 🔻35.84x
█░░░░░░░░░░░░░░░
125 Mbps 🔻28.24x
Base-32 convertlib ████████████████
3.7 Gbps 🌟
████████████████
4.38 Gbps 🌟
████████████████
3.24 Gbps 🌟
base_codecs █░░░░░░░░░░░░░░░
307 Mbps 🔻12.05x
█░░░░░░░░░░░░░░░
254 Mbps 🔻17.24x
█░░░░░░░░░░░░░░░
224 Mbps 🔻14.46x
base32 █░░░░░░░░░░░░░░░
244 Kbps 🔻15163.93x
█░░░░░░░░░░░░░░░
58.5 Mbps 🔻74.87x
█░░░░░░░░░░░░░░░
59.98 Mbps 🔻54.02x
Base-36 convertlib ████████████████
199 Mbps 🌟
████████████████
1.12 Gbps 🌟
BigInt █░░░░░░░░░░░░░░░
5.59 Mbps 🔻35.6x
█░░░░░░░░░░░░░░░
20.13 Mbps 🔻55.64x
Base-45 convertlib ████████████████
4.39 Gbps 🌟
████████████████
5.18 Gbps 🌟
████████████████
3.97 Gbps 🌟
Base-58 convertlib ████████████████
164 Mbps 🌟
████████████████
1.35 Gbps 🌟
base_codecs █░░░░░░░░░░░░░░░
2.07 Mbps 🔻79.23x
█░░░░░░░░░░░░░░░
51.53 Mbps 🔻26.18x
Base-62 convertlib ████████████████
210 Mbps 🌟
████████████████
1.22 Gbps 🌟
base_x █░░░░░░░░░░░░░░░
3.55 Mbps 🔻59.02x
█░░░░░░░░░░░░░░░
46.13 Mbps 🔻26.38x
Base-64 convertlib ████████████████
4.35 Gbps 🌟
████████████████
5.04 Gbps 🌟
████████████████
3.75 Gbps 🌟
dart:convert ████████████░░░░
3.33 Gbps 🔻1.31x
████████████░░░░
3.72 Gbps 🔻1.36x
████████████░░░░
2.72 Gbps 🔻1.38x
Base-85 convertlib ████████████████
4.03 Gbps 🌟
████████████████
4.6 Gbps 🌟
████████████████
3.57 Gbps 🌟
base_codecs ████████░░░░░░░░
1.98 Gbps 🔻2.04x
████████░░░░░░░░
2.38 Gbps 🔻1.93x
██████░░░░░░░░░░
1.29 Gbps 🔻2.76x
Z85 convertlib ████████████████
3.99 Gbps 🌟
████████████████
4.56 Gbps 🌟
████████████████
3.58 Gbps 🌟
base_codecs █████████░░░░░░░
2.29 Gbps 🔻1.74x
█████████░░░░░░░
2.58 Gbps 🔻1.77x
█████████░░░░░░░
1.96 Gbps 🔻1.83x
Bech32 convertlib ████████████████
1.21 Gbps 🌟
████████████████
1.3 Gbps 🌟
████████████████
953 Mbps 🌟
Punycode convertlib ████████████████
751 Mbps 🌟
████████████████
782 Mbps 🌟
████████████████
777 Mbps 🌟
IMAP UTF-7 convertlib ████████████████
1.06 Gbps 🌟
████████████████
1.15 Gbps 🌟
████████████████
1.08 Gbps 🌟
Percent convertlib ████████████████
1.87 Gbps 🌟
████████████████
2.19 Gbps 🌟
████████████████
1.64 Gbps 🌟
dart:core ████░░░░░░░░░░░░
486 Mbps 🔻3.84x
████░░░░░░░░░░░░
512 Mbps 🔻4.27x
███░░░░░░░░░░░░░
340 Mbps 🔻4.82x
Quoted-Printable convertlib ████████████████
1.32 Gbps 🌟
████████████████
1.52 Gbps 🌟
████████████████
1.2 Gbps 🌟
UTF-8 convertlib ████████████████
2.57 Gbps 🌟
████████████████
2.82 Gbps 🌟
████████████████
2.3 Gbps 🌟
dart:convert ███████████░░░░░
1.82 Gbps 🔻1.41x
███████████░░░░░
1.95 Gbps 🔻1.45x
███████████░░░░░
1.63 Gbps 🔻1.41x
UTF-8 (ASCII) convertlib ████████████████
7.34 Gbps 🌟
████████████████
7.86 Gbps 🌟
████████████████
7.03 Gbps 🌟
dart:convert ████████░░░░░░░░
3.72 Gbps 🔻1.97x
████████░░░░░░░░
3.91 Gbps 🔻2.01x
███████░░░░░░░░░
2.97 Gbps 🔻2.37x
UTF-16 convertlib ████████████████
2.47 Gbps 🌟
████████████████
2.7 Gbps 🌟
████████████████
2.18 Gbps 🌟
UTF-32 convertlib ████████████████
2.25 Gbps 🌟
████████████████
2.67 Gbps 🌟
████████████████
2.18 Gbps 🌟

Decoding #

Codec Library 1MB message 1KB message 32B message
Base-2 convertlib ████████████████
1.26 Gbps 🌟
████████████████
1.31 Gbps 🌟
████████████████
1.25 Gbps 🌟
Base-8 convertlib ████████████████
3.28 Gbps 🌟
████████████████
3.59 Gbps 🌟
████████████████
3.06 Gbps 🌟
Base-16 convertlib ████████████████
1.69 Gbps 🌟
████████████████
1.86 Gbps 🌟
████████████████
1.63 Gbps 🌟
base_codecs ██░░░░░░░░░░░░░░
160 Mbps 🔻10.56x
█░░░░░░░░░░░░░░░
164 Mbps 🔻11.34x
██░░░░░░░░░░░░░░
158 Mbps 🔻10.32x
convert ██████░░░░░░░░░░
682 Mbps 🔻2.48x
██████░░░░░░░░░░
692 Mbps 🔻2.69x
██████░░░░░░░░░░
636 Mbps 🔻2.56x
hex ██░░░░░░░░░░░░░░
159 Mbps 🔻10.63x
█░░░░░░░░░░░░░░░
162 Mbps 🔻11.48x
█░░░░░░░░░░░░░░░
149 Mbps 🔻10.94x
Base-32 convertlib ████████████████
3.09 Gbps 🌟
████████████████
3.16 Gbps 🌟
████████████████
2.57 Gbps 🌟
base_codecs █░░░░░░░░░░░░░░░
203 Mbps 🔻15.23x
█░░░░░░░░░░░░░░░
204 Mbps 🔻15.49x
█░░░░░░░░░░░░░░░
182 Mbps 🔻14.15x
base32 █░░░░░░░░░░░░░░░
104 Mbps 🔻29.63x
█░░░░░░░░░░░░░░░
152 Mbps 🔻20.79x
█░░░░░░░░░░░░░░░
119 Mbps 🔻21.68x
Base-36 convertlib ████████████████
409 Mbps 🌟
████████████████
1.7 Gbps 🌟
BigInt █░░░░░░░░░░░░░░░
27.14 Mbps 🔻15.07x
█░░░░░░░░░░░░░░░
47.25 Mbps 🔻35.87x
Base-45 convertlib ████████████████
3.63 Gbps 🌟
████████████████
3.73 Gbps 🌟
████████████████
3.29 Gbps 🌟
Base-58 convertlib ████████████████
397 Mbps 🌟
████████████████
1.84 Gbps 🌟
base_codecs █░░░░░░░░░░░░░░░
2.34 Mbps 🔻169.54x
█░░░░░░░░░░░░░░░
63.08 Mbps 🔻29.17x
Base-62 convertlib ████████████████
407 Mbps 🌟
████████████████
1.84 Gbps 🌟
base_x █░░░░░░░░░░░░░░░
5.11 Mbps 🔻79.62x
█░░░░░░░░░░░░░░░
161 Mbps 🔻11.43x
Base-64 convertlib ████████████████
3.61 Gbps 🌟
████████████████
3.72 Gbps 🌟
████████████████
3.05 Gbps 🌟
dart:convert ██████████░░░░░░
2.21 Gbps 🔻1.63x
██████████░░░░░░
2.24 Gbps 🔻1.66x
██████████░░░░░░
1.82 Gbps 🔻1.68x
Base-85 convertlib ████████████████
4.45 Gbps 🌟
████████████████
4.58 Gbps 🌟
████████████████
3.33 Gbps 🌟
base_codecs █░░░░░░░░░░░░░░░
41.14 Mbps 🔻108.17x
█░░░░░░░░░░░░░░░
47.28 Mbps 🔻96.87x
█░░░░░░░░░░░░░░░
40.9 Mbps 🔻81.45x
Z85 convertlib ████████████████
4.45 Gbps 🌟
████████████████
4.59 Gbps 🌟
████████████████
3.55 Gbps 🌟
base_codecs █░░░░░░░░░░░░░░░
51.53 Mbps 🔻86.36x
█░░░░░░░░░░░░░░░
51.28 Mbps 🔻89.51x
█░░░░░░░░░░░░░░░
47.3 Mbps 🔻75.08x
Bech32 convertlib ████████████████
834 Mbps 🌟
████████████████
878 Mbps 🌟
████████████████
683 Mbps 🌟
Punycode convertlib ████████████████
612 Mbps 🌟
████████████████
629 Mbps 🌟
████████████████
610 Mbps 🌟
IMAP UTF-7 convertlib ████████████████
511 Mbps 🌟
████████████████
531 Mbps 🌟
████████████████
457 Mbps 🌟
Percent convertlib ████████████████
1.62 Gbps 🌟
████████████████
1.68 Gbps 🌟
████████████████
1.37 Gbps 🌟
dart:core ██░░░░░░░░░░░░░░
213 Mbps 🔻7.61x
████░░░░░░░░░░░░
442 Mbps 🔻3.8x
█████░░░░░░░░░░░
395 Mbps 🔻3.47x
Quoted-Printable convertlib ████████████████
2.06 Gbps 🌟
████████████████
2.12 Gbps 🌟
████████████████
1.68 Gbps 🌟
UTF-8 convertlib ████████████████
1.21 Gbps 🌟
████████████████
1.29 Gbps 🌟
████████████░░░░
843 Mbps
dart:convert ████████████████
1.21 Gbps 🔻1x
███████████████░
1.24 Gbps 🔻1.04x
████████████████
1.13 Gbps 🔺1.34x
UTF-8 (ASCII) convertlib ████████████████
28.6 Gbps
███████████████░
76.68 Gbps
██████████████░░
9.51 Gbps
dart:convert ████████████████
28.74 Gbps 🔺1x
████████████████
81.86 Gbps 🔺1.07x
████████████████
10.71 Gbps 🔺1.13x
UTF-16 convertlib ████████████████
705 Mbps 🌟
████████████████
727 Mbps 🌟
████████████████
562 Mbps 🌟
UTF-32 convertlib ████████████████
587 Mbps 🌟
████████████████
606 Mbps 🌟
████████████████
498 Mbps 🌟

BigInt #

Codec Library 4KB message 256B message 32B message
bytes → BigInt convertlib ████████████████
504 Mbps 🌟
████████████████
583 Mbps 🌟
████████████████
692 Mbps 🌟
hex + BigInt.parse ██████░░░░░░░░░░
187 Mbps 🔻2.7x
█████░░░░░░░░░░░
182 Mbps 🔻3.2x
██░░░░░░░░░░░░░░
93.45 Mbps 🔻7.4x
pointycastle █░░░░░░░░░░░░░░░
12.42 Mbps 🔻40.57x
███░░░░░░░░░░░░░
102 Mbps 🔻5.72x
████░░░░░░░░░░░░
188 Mbps 🔻3.68x
BigInt → bytes convertlib ████████████████
818 Mbps 🌟
████████████████
957 Mbps 🌟
████████████████
991 Mbps 🌟
toRadixString + fromHex ███░░░░░░░░░░░░░
147 Mbps 🔻5.56x
██░░░░░░░░░░░░░░
145 Mbps 🔻6.6x
██░░░░░░░░░░░░░░
130 Mbps 🔻7.62x
pointycastle █░░░░░░░░░░░░░░░
32.95 Mbps 🔻24.81x
███░░░░░░░░░░░░░
192 Mbps 🔻4.98x
████░░░░░░░░░░░░
273 Mbps 🔻3.63x

Crypt #

Codec Library argon2id (96 chars) bcrypt (60 chars)
fromCrypt convertlib ████████████████
997 Mbps 🌟
████████████████
1.43 Gbps 🌟
toCrypt convertlib ████████████████
655 Mbps 🌟
████████████████
1.06 Gbps 🌟

All benchmarks are done on AMD Ryzen 7 5800X CPU + 3200MHz RAM using compiled exe

Dart SDK version: 3.14.0 (stable) (Wed Nov 4 16:28:39 2026 -0800) on "windows_x64"

📄 License #

BSD 3-Clause License. See the LICENSE file for details. Issues and contributions are welcome at github.com/bitanon/convertlib.

5
likes
160
points
49.4k
downloads

Documentation

API reference

Publisher

verified publisherbitanon.dev

Weekly Downloads

Fast, zero-dependency codecs for Base2/8/16/32/36/45/58/62/64/85, Bech32, Punycode, percent (URL), quoted-printable, BigInt, UTF-8, and the PHC/crypt format.

Homepage
Repository (GitHub)
View/report issues

Topics

#encoding #base64 #base58 #base32 #hex

Funding

Consider supporting this project:

paypal.me

License

BSD-3-Clause (license)

More

Packages that depend on convertlib