SnippetsLab defines a JSON library format and can import data from any .json file that conforms to the required format, as discussed below. This makes it possible to import from arbitrary third-party sources as long as they are converted to the supported format first.
The JSON format is designed to support the app’s full feature set while allowing users to use only a subset of features. For example, you can generate and import a JSON file that contains only snippets (no folders, tags, etc.). Most attributes are optional, with a few exceptions that are marked as “required” in the description.
Schema
Root
Key path: (root)
Field
Type
Description
contents
Dictionary
A dictionary containing all folders, snippets, smart groups, tags, and shortcuts. Required.
Contents
Key path: (root).contents
Field
Type
Description
folders
[Folder]
An array of all root-level folders.
snippets
[Snippet]
An array of all snippets.
smartGroups
[SmartGroup]
An array of all smart groups.
tags
[Tag]
An array of all tags.
shortcuts
[Shortcut]
An array of all shortcuts.
Folder
Key path: (root).contents.folders[*].
Field
Type
Description
title
String
Name of the folder.
uuid
String
Unique identifier. See discussion. Required.
children
[Folder]
An array of subfolders inside the folder.
Snippet
Key path: (root).contents.snippets[*].
Field
Type
Description
title
String
Name of the snippet. Required.
folder
String
UUID of the folder that this snippet belongs to.
tags
[String]
An array of UUIDs of tags assigned to this snippet.
pinned
Boolean
Indicates whether this snippet is pinned.
dateCreated
String
Creation date of the snippet. See discussion.
dateModified
String
Last modification date of the snippet. See discussion.
fragments
[Fragment]
An array of fragments. Each snippet must have at least one fragment. Required.
Fragment
Key path: (root).contents.snippets[*].fragments[*].
Field
Type
Description
title
String
Name of the fragment. This is often omitted if there is only one fragment.
note
String
Text for the notes area.
noteAttributes
[NotesAttribute]
Rich text attributes for the notes.
content
String
The content of the snippet. Required.
language
String
Language of the fragment. See discussion.
dateCreated
String
Creation date of the fragment. See discussion.
dateModified
String
Last modification date of the fragment. See discussion.
Smart Group
Key path: (root).contents.smartGroups[*].
Field
Type
Description
title
String
Name of the smart group.
uuid
String
Unique identifier. See discussion. Required.
predicate
String
Search predicate of the smart group. See discussion. Required.
Tag
Key path: (root).contents.tags[*].
Field
Type
Description
title
String
Name of the tag.
uuid
String
Unique identifier. See discussion. Required.
Shortcut
Key path: (root).contents.shortcuts[*].
Field
Type
Description
uuid
String
Unique identifier of the folder, smart group or tag that this shortcut links to. Required.
Note Attribute
Key path: (root).contents.snippets[*].fragments[*].noteAttributes[*].
Field
Type
Description
name
String
Name of the attribute, for example strong, underline, link, etc. Required.
range
[Int]
Range of this attribute, in the format of [location, length]. The offsets are measured in UTF-16 code units. Required.
stringValue
String
An optional string value for the attribute, currently only used for the link attribute, where this should be the URL for the link.
Discussion
UUID: In the JSON format, UUIDs are used for cross-referencing between entities. For example, each folder must have a uuid, whose value is then referenced by all snippet located within the folder. Similarly, a shortcut references the target folder, smart group, or tag with their UUID. The UUIDs do not have to conform to any specific format, but they must be unique across all UUIDs in the JSON file.
Date: All dates, such as dateCreated and dateModified, are formatted as strings that conform to the ISO 8601 standard. For example, 2011-08-29T20:34:41Z.
Language: In a fragment, the language is expressed by a Pygments lexer name. See Pygments documentation for a complete list. Note that some languages listed there may not be supported by SnippetsLab.
Predicate: Each smartGroup must have a predicate attribute indicating the search criteria. This predicate is used by NSPredicate internally.
Example
{
"contents": {
"folders": [
{
"title": "Publishing",
"uuid": "D3F0277B-6230-46C1-9D2E-3E1B8CE509BF"
},
{
"title": "Graphic Design",
"uuid": "D42BB115-44C4-4931-ACF8-8AD5F2D1778C",
"children": [
{
"title": "Subfolder 1",
"uuid": "4D356EC0-6118-4DDE-B09C-EC4116698877",
},
{
"title": "Subfolder 2",
"uuid": "2C6E47F2-A23F-4B4D-B63E-B1C37973A7BC",
}
]