Use the DirtyMarkup API to programmatically clean your code. This service is currently offered free of charge, but is subject to change at any time.
To clean your HTML, send the following request:
POST https://www.10bestdesign.com/dirtymarkup/api/html
code
– your dirty HTML code.
indent
– preferred format for indentation. Use “tabs” for tabs or
2, 4 (default), or 8 for spaces.
line-length
– the preferred line length at which to wrap
code. Defaults to 80.
output
– the output style. Can be “full-page” (default) or
“fragment”.
indent-style
– the indentation style. Can be “auto” (default),
“block”, or “none”.
add-empty-lines
– whether or not to add empty lines for clarity.
Can be true or false (default).
allow-proprietary-attribs
– whether or not to allow non-standard
attributes in HTML tags. Can be true or false (default).
optimize-for-ms-word
– this option can optimize the cleaning
process to better handle HTML files saved by Microsoft Word. Can be true or
false (default).
To clean your CSS, send the following request:
POST https://www.10bestdesign.com/dirtymarkup/api/css
code
– your dirty CSS code.indent
– preferred format for indentation. Use “tabs” for tabs or
2, 4 (default), or 8 for spaces.
newline-between-rules
– whether or not to add a newline between each
CSS rule. Can be true or false (default).
newline-between-selectors
– whether or not to add a newline
between multiple selectors. Can be true or false (default).
Note: the “Preferred line length” option doesn’t have any effect on CSS code. It only sets the visual ruler in the editor, so there is nocorresponding API parameter.
To clean your JavaScript, send the following request:
POST https://www.10bestdesign.com/dirtymarkup/api/js
code
– your dirty JavaScript code.
indent
– preferred format for indentation. Use “tabs” for tabs or
2, 4 (default), or 8 for spaces.
line-length
– the preferred line length at which to wrap
code. Defaults to 80.
brace-style
– the format for braces. Can be “collapse”,
“collapse-preserve-inline”, “expand”, or “end-expand”.
spaces-in-parenthesis
– adds whitespace inside parenthesis. Can
be true or false (default).
break-chained-methods
– breaks chained method calls into their own
lines. Can be true or false (default).
commas-at-beginning
– Places commas at the beginning of the new lines
instead of at the end. Can be true or false (default).
keep-array-indentation
– preserves array indentation. Can be true
or false (default).
preserve-empty-lines
– Preserves empty newlines. Can be true or
false (default).
Every request to the API will return one of the following HTTP codes.
200 Success
– Everything went well. 👍418 I’m a teapot
– You have been blocked due to abuse. ☠️429 Too Many Requests
– You have exceeded the daily rate limit. 🔨500 Internal Server Error
– Something broke on our end. 🐞Successful responses will contain a JSON string:
{"clean": "your clean code"}
DirtyMarkup has a soft rate limit of 1,000 requests per day per IP address. If you consistently exceed the limit, your IP address will be blacklisted to preserve resources for other users.
Again, DirtyMarkup is a free service. If your application will require significant usage of the API, please contact @10bestdesign about sponsoring the service before launching.
DirtyMarkup is a free service built by Cory LaViska and provided as a courtesy by his company, A Beautiful Site, LLC. DirtyMarkup is offered without warranty of any kind. Use of DirtyMarkup and its API is strictly at your own risk. DirtyMarkup does not retain any of your code or personal information for any reason.
If you made something cool with the API, need help, or would like to report a bug, please contact @10bestdesign.