references/messages-schema.md — Message History Reader for iMessage and SMS

From version 0.1.1 of Message History Reader for iMessage and SMS, shown publicly by its creator. 2.0 KiB · SHA-256 029322c64e8c67c50797bb80a4355dca34befdf6c8cdb852aa01db59aac50676.

# Messages database notes

The CLI uses a small subset of the local Messages SQLite schema: `chat` for
conversation identifiers, `handle` and `chat_handle_join` for participants,
`message` for dates, direction, text, and `attributedBody`, and
`chat_message_join` for chat-to-message links. Actual columns and relationships can vary
with macOS. If the CLI reports an unsupported schema, stop rather than
guessing a query against private data.

## Time and body handling

Apple message times are relative to 2001-01-01. Older databases store
seconds; newer databases store nanoseconds. The CLI chooses the unit by
magnitude and renders normalized dates. `message.text` takes precedence.
When it is null, the CLI extracts only a supported string payload from the
NSAttributedString typedstream in `attributedBody`. This minimal reader does
not deserialize arbitrary objects. An undecodable body is counted as skipped,
marks the result `incomplete`, and causes exit status `2` unless the caller
uses `--allow-partial`.

## Transcript

An export contains `messages.jsonl` and `transcript.txt`. The latter uses a
timestamp and speaker header, with continuation lines indented:

```text
2026-09-30T12:00:00  sender: first content line
    | next content line
```

Every line break is handled as a continuation. Tabs, control characters, and
format characters become visible Unicode escapes so message content cannot
forge another speaker's header. The JSONL file keeps structured message
content and can contain raw personal data.

An export only creates files in a new or empty, non-symlink output directory.
Dry-run creates no export files but still creates and removes the private
`0700` temporary database copy, honouring `TMPDIR`. Live export requires the
dry-run digest bound to the
chat, resolved destination, existing parent/directory device and inode identities,
creation action and rendered content. The copies are sequential, not an atomic
snapshot of an actively changing database. Each input file is limited to 128 MiB. Keep exports local and private.

By Zero Width Lab (zerowidthlab.com)

License: MIT (read it).

MITMIT License

Copyright (c) 2026 Zero Width Lab

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Back to the listing