For AI agents: the complete documentation index is available at https://anyformat.swc.rs/llms.txt, the full documentation bundle is available at https://anyformat.swc.rs/llms-full.txt, and this page is available as Markdown at https://anyformat.swc.rs/api/index.md.

API reference

Each format family is one package for Node.js and one package for Python. The two packages of a family have the same functions and options. Some Node.js functions also have a synchronous form with the Sync suffix, and the image family also has the constant formatSupport (FORMAT_SUPPORT in Python).

FamilyNode.js functionsPython functions
Imagedetect, supportedFormats, readImageInfo, decode, encode, compareImages, resize, crop, alphaBoundsdetect, supported_formats, read_image_info, decode, encode, compare_images, resize, crop, alpha_bounds
Audiodetect, supportedFormatsdetect, supported_formats
Videodetect, supportedFormatsdetect, supported_formats
Fontdetect, supportedFormatsdetect, supported_formats
PDFisPdf, detectVersionis_pdf, detect_version
Officedetect, supportedFormatsdetect, supported_formats

Input

The functions take the bytes of a file: a Uint8Array in Node.js, for example a Buffer, and bytes in Python. Some families also accept other inputs; the image family, for example, accepts any object with the buffer protocol in Python, and raw images in encode, compareImages, resize, crop, and alphaBounds. The detection functions read only the leading bytes, so you can give them the start of a file and not the whole file. The page of each family tells how many bytes it needs. The functions that decode a file, for example decode of the image family, need the whole file.

Names in each language

The Node.js API uses camel case, and the Python API uses snake case. A null result in Node.js is None in Python.