# AnyBlock
AnyBlock is Anytype's open interchange project. It contains both generations
of the format, the codecs between them, bundle tooling, and conformance data.
- **AnyBlock v1** is the protobuf wire format used by Anytype for models,
events, changes, and snapshots.
- **AnyBlock v2** is the readable, interoperable import/export and API-base
format. Its first public `formatVersion` is `2.0`; later grammar revisions
in this family use `2.1`, `2.2`, and so on.
## Start here
**You have an export and want to read it.** →
**[format/v2/READING.md](format/v2/READING.md)** — nine steps from a directory
of JSON to titles, property values, links and page text, needing no Anytype
software and nothing from this repository. It is runnable; the reader is one
standard-library Go program that imports no part of this module:
```sh
go run ./format/v2/examples/reader ./format/v2/examples/exported_space
go run ./format/v2/examples/reader /path/to/your/export <object-id>
```
| you want to | go to |
|---|---|
| read an export | [format/v2/READING.md](format/v2/READING.md) |
| parse the text inside a block | [format/v2/INLINE_MARKUP.md](format/v2/INLINE_MARKUP.md) |
| write a bundle by hand | [format/v2/examples/habit_tracker](format/v2/examples/habit_tracker), then SPEC §2g |
| check a bundle you produced | `go run ./cmd/anyblock validate <dir>` |
| know why the format is shaped this way | [format/v2/README.md](format/v2/README.md) |
| look a rule up, normatively | [format/v2/SPEC.md](format/v2/SPEC.md) |
| convert v1 snapshots in Go | [codec/anyblockjson](codec/anyblockjson) |
## Repository layout
```text
format/v1/ v1 protobuf sources, generated Go bindings, conformance data
format/v2/ v2 specification, JSON schemas, examples, conformance data
codec/anyblockjson/ Go codec between v1 snapshots and v2 documents
bundle/ v2 bundle validation and composition
cmd/anyblock/ command-line validation and conversion tools
js/ future JavaScript/Wasm packages
```
A caller imports the two together — v1 types in, AnyBlock JSON out:
```go
import (
"github.com/anyproto/any-block/codec/anyblockjson"
v1 "github.com/anyproto/any-block/format/v1/model"
)
```
`format/v1` and `format/v2` own the wire/JSON format artifacts, `codec/anyblockjson`
is the Go conversion API, and `bundle` and `cmd/anyblock` provide the bundle
and command-line surfaces. `Options.TableColumnHeaders` remains opt-in so
backup output is stable.
For the v1 side, start with [format/v1/README.md](format/v1/README.md). The
normative v2 definition is [format/v2/SPEC.md](format/v2/SPEC.md); it is long,
and reading an export does not require it.
## Development
```sh
go test ./...
go vet ./...
go generate ./codec/anyblockjson ./format/v1
```
The format and codec READMEs list the pinned generator installation commands
used by CI.
Fixture and corpus rules for contributors are in
[FIXTURE_POLICY.md](FIXTURE_POLICY.md).
## Contribution
Thank you for your desire to develop Anytype together!
❤️ This project and everyone involved in it is governed by the [Code of Conduct](https://github.com/anyproto/.github/blob/main/docs/CODE_OF_CONDUCT.md).
🧑💻 Check out our [contributing guide](https://github.com/anyproto/.github/blob/main/docs/CONTRIBUTING.md) to learn about asking questions, creating issues, or submitting pull requests.
🫢 For security findings, please email [security@anytype.io](mailto:security@anytype.io) and refer to our [security guide](https://github.com/anyproto/.github/blob/main/docs/SECURITY.md) for more information.
🤝 Follow us on [Github](https://github.com/anyproto) and join the [Contributors Community](https://github.com/orgs/anyproto/discussions).
---
Made by Any — a Swiss association 🇨🇭
Licensed under [MIT](./LICENSE.md).