Use Cases
- Testing HTML snippets before embedding them in production
- Previewing email templates in HTML format
- Debugging CSS styles and layout issues
- Rendering user-generated content safely (e.g., from a CMS)
- Validating responsive designs with different viewport sizes
- Inspecting HTML from web scraping or API responses
How It Works
The tool takes raw HTML input and renders it in an iframe sandbox with restricted permissions. This prevents malicious scripts from accessing the parent page or making network requests.The iframe uses sandbox attributes to isolate the content:
allow-same-origin: Allows rendering within the iframe- No
allow-scripts: JavaScript is disabled by default for security - No
allow-forms: Form submissions are blocked
Input Format
Any valid HTML, from simple snippets to complete documents:Output
The tool displays:- HTML source in the output pane (for reference)
- Live preview in the preview pane (iframe rendering)
Examples
Security Features
Sandbox Restrictions
The iframe usessandbox attributes to prevent:
- Script execution:
<script>tags are ignored - Form submission: Forms cannot be submitted
- Popups:
window.open()and similar are blocked - Top-level navigation: Cannot change the parent page URL
- Plugin loading:
<embed>,<object>,<applet>are blocked
Safe for User-Generated Content
Because scripts are disabled, you can safely preview:- HTML from untrusted sources (user comments, CMS content)
- Scraped web pages
- Third-party widgets (in display-only mode)
Technical Details
Located in
lib/tools/engine.ts:483-484output: The raw HTML (displayed in the output pane)previewHtml: The HTML to render in the iframe (preview pane)
Preview Pane Implementation
The preview pane (inToolWorkbench.tsx) creates a sandboxed iframe:
Limitations
Why doesn't JavaScript work?
Why doesn't JavaScript work?
JavaScript is intentionally disabled for security. The iframe sandbox prevents script execution to protect against XSS attacks. If you need to test interactive JavaScript, use a local HTML file or a service like CodePen.
Can I preview external CSS/images?
Can I preview external CSS/images?
Yes! External resources (CSS, images, fonts) loaded via
<link> or <img> will work if they are publicly accessible. However, resources blocked by CORS or requiring authentication may not load.Why does my layout look different than in production?
Why does my layout look different than in production?
The preview pane has a default white background and no base styles. Your production site may have global CSS resets, base fonts, or container styles that affect rendering. For the most accurate preview, include all necessary inline styles or
<style> tags.Common Patterns
Inline Styles for Email Templates
Email clients often strip<style> tags, so use inline styles:
Testing Responsive Design
Use CSS media queries and resize the preview pane:Complete HTML Document
Related Tools
- HTML Entity Encode/Decode - Escape HTML special characters
- HTML Beautify/Minify - Format HTML for readability
- HTML to JSX - Convert HTML to React JSX
- Markdown Preview - Render Markdown as HTML