HTML Formatter

HTML Formatter

Format HTML with 2- or 4-space indentation and a preferred line width. Uses strict HTML whitespace handling and does not separately format embedded script or style code.

Input and results are processed in browser memory; this tool does not upload or store them. Reloading clears them. Site-wide advertising and analytics may operate separately, but tool usage events do not contain your input or output.

Comments & questions

HTML Formatter

Make HTML source easier to read with consistent indentation and line wrapping. Spaces between inline elements can change sentence content, so formatting treats whitespace around every tag as significant. Input is processed as source text and is never rendered or executed as a preview.

Key features

  • Choose 2- or 4-space indentation
  • Set a preferred line width of 80, 100 or 120
  • Use strict HTML whitespace handling and LF line endings
  • Keep embedded-language formatting disabled for script and style

How to use

  1. Paste a complete HTML document or fragment.
  2. Choose indentation and a preferred line width.
  3. Run the formatter and inspect tag structure and whitespace.
  4. Copy the result, then separately test rendering, accessibility and script behavior in your own page.

Use cases

  • Read an HTML template received on one line
  • Standardize tag indentation before code review
  • Prepare markup examples for documentation

Frequently asked questions

Can I preview the rendered page?

This tool formats source only and does not render input HTML. Script, iframe and image URLs in the input are not executed or loaded from that markup.

Why can a line exceed my chosen width?

Print width is a formatting preference rather than a hard character limit. Long URLs, attribute values and content that cannot be split without changing whitespace may remain longer.

Why are some tag boundaries wrapped unexpectedly?

The formatter uses Prettier’s strict HTML whitespace mode, which treats whitespace around every tag as significant. Tag boundaries are wrapped according to those rules. Actual page layout still needs separate testing.

Does it format JavaScript and CSS inside tags?

Embedded-language formatting is disabled, so script and style content is not separately reformatted. The containing HTML tags can still change. Use the dedicated JavaScript or CSS tool for minification.

Does a successful result prove the HTML is valid?

No. Formatting is not an HTML conformance, accessibility or security audit. Syntax the parser cannot handle produces an error, but a formatted result alone does not prove the page is correct.

What changes, and how much input is supported?

Input is limited to 100,000 UTF-16 code units. Indentation and source layout can change, and line endings become LF. Keep the original file and review output containing template-engine syntax.

Privacy

Input and results are processed in browser memory; this tool does not upload or store them. Reloading clears them. Site-wide advertising and analytics may operate separately, but tool usage events do not contain your input or output.

References

Related Tools

HTML to MarkdownHTML Tag RemoverHTML Entity ConverterWasm Module InspectorHreflang Matrix CheckerAST Query PlaygroundContainer Build GraphDependency Graph ExplorerSemver Range LabCron Schedule AuditorPatch Review WorkbenchSource Map ExplorerLocalization Catalog AuditorStructured Data ReviewerHTTP Archive AnalyzerWebhook Signature LabProtobuf Schema WorkbenchGraphQL Schema LabAvro Schema EvolutionLocal SQL WorkbenchSchema Form BuilderMesh Repair WorkbenchPipe Network LabRobot Arm Kinematics LabThermal Network LabBeam Response LabGear Train DesignerTolerance Stackup LabSensor Calibration FitPCB Stackup PlannerDigital Filter DesignerNetwork Reachability MapSun Shadow MapGPS Error SimulatorDigital Logic SimulatorAnalog Circuit LabMechanism Linkage LabAnalysis Mesh GeneratorOpenAPI Contract InspectorDatabase Migration PlannerDimensional Equation CheckerTruss Force LabBoolean Minimization LabControl Response LabQueueing Simulation LabGeofence Event SimulatorCoordinate Reference LabSurvey Traverse LabRaster Classification LabChoropleth Design LabMap Print ComposerRaster Reprojection LabElevation Contour MakerTerrain Viewshed LabWatershed DelineatorMap Tile PackagerText File Encoding WorkbenchFilesystem Portability AuditorSBOM License ExplorerFile Signature Auditornpm Lockfile Conflict ResolverSource Secret AuditorOffline Web Package BuilderCertificate Chain InspectorTorrent Metainfo InspectorChunked File PackagerEncrypted File VaultDuplicate File FinderArchive WorkbenchDesign Token ManagerSpacing Token DesignerResponsive Type SystemPackaging Dieline DesignerSVG Icon Sprite PackerFlex Layout PlaygroundCSS Grid PlaygroundRegex Equivalence LabMarkdown Repository AuditorLog Template MinerResponsive Layout AuditorEmail Template PreviewInternal Link GraphState Machine TesterPetri Net SimulatorGit History VisualizerCurl Request WorkbenchBinary Protocol DesignerHex File EditorBinary Patch WorkbenchFile Signature WorkbenchAPI Mock SandboxSchema Column MapperEvent Log SessionizerER Diagram DesignerTime Series Gap AuditorStratified Data SplitterData Lineage DesignerDecision Tree LabData Anonymization WorkbenchData Expectation RunnerJSON Schema ValidatorBasket Pattern AnalyzerRobots Policy TesterSEO HTML AuditorAccessibility Structure AuditorSyndication Feed WorkbenchIndexNow Payload BuilderCrawl Log AnalyzerCSP Policy WorkbenchSearch Performance AnalyzerCSV Formula Risk AuditorCORS Response SimulatorCache Header LabCookie Policy InspectorWeb Vitals Trace LabSitemap Health AuditorBatch File RenamerFile Manifest VerifierFolder Space MapFolder Difference ReviewerRoute Order OptimizerGeoJSON Map EditorPolygon Overlay LabCartographic Label PlacerSpatial Table JoinGeoJSON Topology AuditorGPX Track AnalyzerTrack Privacy RedactorCSV Table JoinCSV Pivot WorkbenchScientific Data ProfilerTabular Cleaning WorkbenchRecord ReconciliationData Dictionary BuilderCanonical Graph AuditorRedirect Plan TesterHTTP response and ping reference testBrowser and System InformationJSON ↔ YAML ConverterXML ↔ JSON ConverterJavaScript MinifierMock Data Generator.gitignore GeneratorLicense GeneratorUser-Agent ParserPassword Strength CheckerCode to ImageXML FormatterHTTP Status Code LookupMIME Type LookupJS & SQL String EscapeCSS Box Shadow GeneratorCSS Gradient GeneratorIndent ConverterNumber Base ConverterUnicode Escape ConverterUnicode InspectorJSON Structure DiffMarkdown Table GeneratorBase64 EncoderJSON FormatterURL EncoderSQL FormatterCron Expression GeneratorRegex TesterUUID GeneratorHash GeneratorTimestamp ConverterJWT DecoderMarkdown PreviewCSS MinifierMeta Tag GeneratorJSON ↔ CSVCase ConverterImage to Base64
Explore all Dev Tools tools →Image/Media →Text/Convert →Life/Fun →