Overview
Turndown is the successor to the to-markdown library. The project was renamed to better reflect its purpose and to provide a fresh start for ongoing development.The
to-markdown package has been deprecated in favor of Turndown. All new projects should use Turndown, and existing projects are encouraged to migrate.Why Migrate?
Turndown offers several improvements over to-markdown:- Active maintenance - Regular updates and bug fixes
- Better API - More intuitive method names and options
- Plugin system - Extensible architecture for adding features
- Improved performance - Optimized HTML parsing and conversion
- Better documentation - Comprehensive guides and examples
- TypeScript support - Type definitions for better IDE support
Quick Migration Steps
Breaking Changes
1. Constructor Required
to-markdown was a function that could be called directly. Turndown requires instantiation:2. Method Naming
Several methods have been renamed for consistency:| to-markdown | Turndown | Description |
|---|---|---|
| N/A (direct call) | turndown() | Convert HTML to Markdown |
toMarkdown.addRule() | addRule() | Add a custom rule |
toMarkdown.keep() | keep() | Keep elements as HTML |
toMarkdown.remove() | remove() | Remove elements |
| N/A | use() | Apply plugins |
3. Options Changes
Some option names have changed:4. GitHub Flavored Markdown (GFM)
GFM support is no longer built-in. It’s now available as a separate plugin:5. Custom Rules API
The API for custom rules has been simplified:6. Filter Function Signature
Filter functions now receive the options object:Complete Migration Example
Here’s a complete before/after example:Official Migration Guide
For detailed migration information, including edge cases and advanced scenarios, refer to the official migration guide:Official Migration Guide
Comprehensive guide on the GitHub wiki with detailed examples and troubleshooting
Common Migration Issues
Issue: “TurndownService is not a constructor”
Solution: Make sure you’re instantiating Turndown withnew:
Issue: GFM Features Not Working
Solution: Install and use the GFM plugin:Issue: Custom Rules Not Applied
Solution: Ensure you’re callingaddRule() on the service instance:
Repository Changes
The Turndown repository has moved:- Old URL:
https://github.com/domchristie/to-markdown - New URL:
https://github.com/mixmark-io/turndown
Backward Compatibility
Turndown does not provide backward compatibility with to-markdown. You must update your code to use the new API. However, the core functionality remains the same, and most migrations can be completed quickly.Need Help?
If you encounter issues during migration:- Check the GitHub Issues for similar problems
- Review the official migration guide
- Open a new issue with details about your migration challenge
Next Steps
Getting Started
Learn the basics of using Turndown
Custom Rules
Extend Turndown with custom conversion rules
GFM Plugin
Add GitHub Flavored Markdown support
API Reference
Explore the complete API documentation