Inside the .clip file format

There is no official specification, so this is what we learned by reading real files while building the viewer. It is aimed at developers and the curious.

Overview

A .clip file is a sequence of binary chunks. One chunk holds a complete SQLite database that describes the document; the other chunks hold the bulk data such as pixel tiles, referenced from the database by an identifier. The format is proprietary and undocumented, so everything below comes from inspecting files and from the open-source work credited on the About page. It may be incomplete or differ between program versions.

The header

A valid file begins with the eight ASCII bytes CSFCHUNK. The header is 24 bytes long, and the first chunk starts directly after it. Checking those eight bytes is how ClipPeak tells a real page file from something that only has the right extension.

A .cmc file is different: it is a plain SQLite database (it begins with SQLite format 3), not a chunked container. It lists the pages of a comic project and contains no pixels, which is why it cannot be opened as an image.

Chunks

Each chunk has a 16-byte header followed by its body:

OffsetSizeMeaning
04 bytesMarker, the ASCII text CHNK
44 bytesChunk name, for example SQLi or Exta
88 bytesBody length, big-endian
16lengthBody

The SQLi chunk body is the SQLite database file, byte for byte. An Exta (external data) chunk begins with the length and text of an identifier that starts with extrnlid, followed by the length of the data and the data itself. The database refers to these identifiers when it needs a block of pixels, a vector stroke list or similar bulk data.

Files that were cut off during copying often still contain a complete database, so a tolerant reader can show something even if the last chunks are missing. A reader that expects a perfect file just reports “damaged”.

The database

The SQLite database is the map of the document. The tables a viewer needs most are:

Canvas
Document size, resolution, unit and the root of the layer tree.
Layer
One row per layer or folder: name, type, opacity, blend mode, visibility, clipping, mask references and the settings of correction, gradient and text layers. Layers form a tree through sibling and child links rather than through a simple order number.
Offscreen
Links a layer to the external block that holds its pixels, together with a small binary attribute record: size, tile grid and pixel packing.
Mipmap and MipmapInfo
The layer pixels at several scales. The first level is the full-resolution image; the others are reduced versions Clip Studio Paint uses for fast zooming.
CanvasPreview
A PNG of the finished artwork, usually reduced in size. Fast to show but not the real resolution.
VectorObjectList
Stroke data of vector layers.
BrushStyle
Brush settings used by strokes.

Pixel tiles

Layer pixels are stored in tiles of 256 × 256 pixels, so a layer is a grid of tiles. Tiles that are fully empty are simply absent; the attribute record gives a default value for such areas. This is why a large, mostly empty layer costs almost nothing.

The pixel block is a series of sub-blocks introduced by UTF-16 big-endian labels such as BlockDataBeginChunk and closed with BlockDataEndChunk. Each tile is compressed with zlib. After decompression the layout depends on the layer's pixel packing, which the attribute record describes:

  • RGBA colour layers, where colour and alpha are stored in separate planes inside the tile.
  • Grayscale with alpha, used for gray-expression layers.
  • Gray only, typical for masks.
  • Monochrome layers that store one bit per pixel.

Why a faithful render is hard

Reading pixels is the easy part. Matching Clip Studio Paint's output means implementing its compositing rules: the formulas of each blend mode, how a clipping mask interacts with a folder, how “Through” folders behave, how correction layers process colour, and how tone and gradient layers are generated from their settings. None of this is written down; it has to be measured. See the rendering accuracy report for how well that works out in practice.

Handling the format yourself

If you are writing your own reader, three practical tips: use a SQLite library for the database (it is ordinary SQLite); treat unknown chunks as skippable; and never trust a length field blindly — clamp it to the end of the file so that truncated files do not crash the parser.

Keep reading

Frequently asked questions

Is this documentation official?
No. It describes what we observed in real files and may be incomplete or wrong for some versions. CLIP STUDIO PAINT is a trademark of CELSYS, Inc., and this site is not affiliated with them.
Can I extract the database from a .clip file myself?
Yes. Find the chunk named SQLi, copy its body to a new file and open it with any SQLite tool. Work on a copy, not the original.