docc2json is a specialized command-line tool designed for developers and technical writers who need to transform Apple's proprietary DocC documentation format into a universally accessible, structured JSON schema. It serves iOS and Swift SDK developers, documentation engineers, and teams building custom documentation websites by parsing the JSON files generated by DocC from .doccarchive bundles or processed documentation folders. The primary purpose is to bridge the gap between Xcode's native documentation system and web-based documentation platforms, enabling the deployment of SDK documentation as a consumable API. This tool meticulously extracts all embedded documentation—including abstracts, discussions, and code examples—and restructures it into a clean, web-optimized JSON format that can be seamlessly integrated into custom frontends, static site generators, or developer portals.
Apple's DocC (Documentation Compiler) is a powerful tool for generating documentation directly from Swift source code, but its output is primarily designed for integration within Xcode and Apple's developer ecosystem. This creates a significant pain point for teams that need to publish SDK documentation on public websites, internal developer portals, or cross-platform documentation systems. The native DocC output is not readily consumable by standard web technologies or documentation frameworks, forcing developers to manually extract or rebuild documentation, which is time-consuming, error-prone, and difficult to maintain. docc2json directly addresses this by automating the conversion process, eliminating the manual effort required to adapt DocC's complex JSON structures for web use, and ensuring documentation remains synchronized with the source code.
One of the tool's major feature groups is comprehensive documentation extraction and structured output generation. It fully parses DocC JSON to extract detailed documentation components, including the abstract (a brief one-line description), the discussion (detailed explanations from ## Discussion sections), and code examples from ## Example sections with full code listings. For methods, it extracts parameter descriptions, return value documentation, and exception documentation for throwing methods. The output is a richly structured JSON schema that includes type representations (classes, structs, actors), protocol representations, and enum representations, each containing their respective properties, methods, initializers, and conformances. This deep extraction ensures that the nuanced documentation written by developers is preserved and transformed into a format that can be rendered beautifully on the web.
admin
Another critical feature group is intelligent protocol conformance processing and smart filtering. The tool automatically unmangles Swift and Objective-C protocol names that appear in DocC output, converting cryptic identifiers like 's8SendableP' or 'Se' into clean, human-readable names like 'Sendable'. It applies smart conformance filtering by default, removing common Swift standard library and framework protocols (such as Sendable, Equatable, Hashable, Codable, Identifiable, View, and Error) from the output to reduce clutter, while keeping custom protocols and third-party framework protocols. Users can customize this filtering using the --filter-protocols flag to exclude specific internal protocols or use --keep-all-conformances for debugging purposes to see all conformances without any filtering applied.
The tool offers flexible type grouping and organization capabilities for better documentation site structure. It supports automatic prefix-based grouping using the --group-by-prefix flag, which intelligently groups related types, protocols, and enums by their name prefixes (e.g., Wish, WishStatus, and WishFilters are grouped under a 'Wish' category). For more granular control, users can define custom grouping configurations via a YAML file, specifying groups by explicit type names, wildcard patterns (like 'Prefix*' or '*Suffix'), and providing group descriptions. Types not matching any configured group are placed in an 'Other' group. This feature enables documentation maintainers to create logical, navigable category structures that mirror the SDK's architectural organization, enhancing the user experience on the final documentation website.
From a technical standpoint, docc2json is built in Go for high performance and operates through a multi-stage pipeline. It begins with file walking to locate and collect all .json files within the DocC output directory. It then employs parallel parsing using goroutines to concurrently parse these JSON files, significantly speeding up processing. The tool reconstructs method signatures from DocC's token arrays, resolves cross-references between symbols, and applies access level filtering (when using the --public-only flag). Finally, it transforms the internal DocC schema into the custom, web-optimized SDK schema and writes the formatted or compact JSON to the specified output path. This efficient architecture allows it to process large documentation sets, such as 38,618 files, in under a second.
The benefits and measurable outcomes for users are substantial in terms of efficiency, consistency, and integration capability. Developers save considerable time and effort by automating the documentation conversion process, which would otherwise require manual scripting or adaptation. It ensures documentation consistency by programmatically extracting all content from the source, reducing the risk of human error or drift between the code and its published docs. The structured JSON output is optimized for web deployment, enabling seamless integration with modern documentation systems, static site generators (like Hugo, Docusaurus, or Next.js), and custom frontend applications. Performance metrics demonstrate its speed, parsing thousands of files in approximately 0.4 seconds with parallel processing and completing full transformation in under a second.
Concrete use cases include generating documentation for public-facing SDK websites where teams need to present iOS library APIs in a searchable, browsable format. For example, a team maintaining an 'AppGramSDK' can run docc2json on their .doccarchive, use the included json2docs command to generate MDX files, and directly populate their Docusaurus site. Another use case is internal developer portals for large organizations that aggregate multiple SDKs; the tool can standardize DocC output from various teams into a unified JSON schema for centralized portal ingestion. It also supports SDK analysis workflows, allowing developers to programmatically inspect SDK structure, conformance relationships, and API surfaces using the generated JSON for auditing or code generation purposes.
The target users are primarily iOS and Swift SDK developers, technical writers, and documentation engineers working on Apple platforms. It integrates with the standard DocC toolchain, requiring DocC-generated documentation (.doccarchive or docs/ folder) as input. The tech stack is Go 1.21+, utilizing dependencies like spf13/cobra for the CLI framework and uber-go/zap for structured logging. While explicit pricing plans are not mentioned in the content, the tool is open-source under the MIT license, implying free usage. It is designed to work with Swift 5.9+ DocC output and has been tested with the AppGramSDK comprising 38,618 documentation files, 129 symbols, and 92 articles.
In summary, docc2json delivers essential value by automating the transformation of Apple's walled-garden DocC documentation into an open, web-friendly JSON format. It solves the critical problem of publishing iOS SDK documentation online by providing a fast, reliable, and feature-rich conversion tool that preserves all documentation details, intelligently structures the output, and enables seamless integration with modern web technologies. For any team distributing Swift libraries or maintaining iOS SDKs, this tool bridges the gap between Xcode's excellent documentation tools and the need for accessible, deployable web documentation.
The primary target audience is iOS and Swift SDK developers, technical writers, and documentation engineers who need to publish Apple library documentation on the web. It serves teams building custom documentation sites, maintaining internal developer portals, or distributing SDKs that require online API references. Users are typically working with Xcode and DocC to document their Swift code but face challenges integrating that output with web-based documentation systems.