A Node.js tool to scrape Confluence spaces and convert them to Markdown files while preserving the page hierarchy.
- π Scrape entire Confluence spaces or individual spaces
- π Convert Confluence storage format to Markdown
- π Preserve page hierarchy in directory structure
- π Handle rate limiting with exponential backoff
- π Maintain page relationships and ordering
# Install dependencies
pnpm install
# Configure your Confluence instance
# Edit utils/index.js:
export const BASE_URL = "http://your-confluence-instance/rest/api";
export const ACCESS_TOKEN = "your-personal-access-token";
# Scrape all spaces
pnpm space:all
# Or scrape a specific space
pnpm space:single ENGINEERINGThis project follows a documented decision-making process. Key architectural decisions:
-
- Native fetch with backoff
- Centralized API client
- Type-safe responses
-
- Feature-based organization
- Clear separation of concerns
- Consistent patterns
-
- Centralized error handling
- Retry mechanisms
- Consistent error messages
-
- Command-based interface
- Progress feedback
- Clear usage instructions
.
βββ scripts/ # CLI Commands
β βββ all-spaces.js # Scrape all spaces
β βββ all-space-content.js # Scrape single space
βββ utils/ # Shared Utilities
β βββ index.js # API client, helpers
βββ docs/ # Documentation
βββ api-examples.md
βββ api-integration.md
βββ cli-interface.md
βββ error-handling.md
βββ file-structure.md
# Format code
pnpm formatThe scraper creates a directory structure that mirrors your Confluence space:
confluence_markdown/
βββ SPACE1/
β βββ home/
β β βββ index.md (Space homepage)
β β βββ Other Root Pages.md
β βββ Parent Page/
β βββ index.md (Parent page content)
β βββ Child Page.md
βββ SPACE2/
βββ ...
Configure your Confluence instance in utils/index.js:
export const BASE_URL = "http://your-confluence-instance/rest/api";
export const ACCESS_TOKEN = "your-personal-access-token";
export const OUTPUT_DIR = "confluence_markdown";The scraper handles several error cases:
- Rate limiting (429) with exponential backoff
- Network errors with retries
- Invalid space keys
- Missing configuration
- File system errors
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
ISC
- markdown-it for Markdown conversion
- jsdom for HTML parsing