ISO 8601 Duration Converter
Convert ISO 8601 duration strings such as P1DT2H30M into seconds, minutes and a plain English description, and build a duration string from any combination of units.
Last reviewed by the Radiatus Cloud team
Decode a duration
Build a duration
Need this built for your product?
We design, build & host secure software & APIs.
The format nobody memorises
ISO 8601 durations turn up in Kubernetes manifests, JSON Schema, XML payloads, YouTube API responses, Java Duration parsing, Azure and AWS policies and schema.org markup. The syntax is compact but genuinely confusing: the letter P starts every duration, the letter T separates the date part from the time part, and M means months before the T and minutes after it. PT1M is one minute and P1M is one month, which is the single most expensive character position in the whole format.
Where the ambiguity lives
Years and months have no fixed length, so a duration containing them cannot be converted to seconds without picking a reference date. A converter that reports P1M as 2,592,000 seconds has silently assumed a 30 day month, which is wrong eleven months of the year. This tool separates the exact part, made of weeks, days, hours, minutes and seconds, from the calendar part, and tells you when a value cannot be expressed exactly rather than pretending it can.
Round tripping and normalisation
The other useful operation is normalisation. PT90M and PT1H30M describe the same span, and different systems accept different forms: some reject a value larger than its unit allows, some reject a week component combined with days. The builder here emits a canonical string with components carried into the next unit, and shows the equivalent raw seconds so you can paste whichever form the target system prefers.
Related tools
- JSON Formatter — Format and beautify JSON in your browser. Pinpoints syntax errors by line and column, flags unsafe integers, and never uploads your data to a server.
- JSON Validator — Validate JSON syntax with precise line and column errors, and check documents against a JSON Schema. Runs locally in your browser, nothing uploaded.
- Regex Tester — Test regular expressions against sample text with live match highlighting, capture groups and flag control. Runs entirely in your browser.
- HTML Minifier — Minify HTML by removing comments and redundant whitespace, without breaking inline elements or pre blocks. Runs entirely in your browser.
Frequently Asked Questions
Why is M ambiguous in this format?
Because the specification reuses the letter. Before the T separator M means months; after it M means minutes. P2M is two months and PT2M is two minutes, and forgetting the T is the classic bug in hand written durations.
Can a duration with months be converted to seconds?
Not exactly. A month is between 28 and 31 days, so any second count is an assumption. The tool reports the exact part separately and shows an approximate total using 30.44 day months only when you ask for it, clearly labelled as approximate.
Are fractional values allowed?
The specification permits a decimal fraction on the smallest component used, so PT0.5H and PT1.5S are valid. Many parsers only accept fractional seconds, so the builder emits whole units where it can.
What is the difference from a duration like 1h30m?
That Go style shorthand is a different format entirely, accepted by Go, Prometheus and some config parsers but not by ISO 8601 consumers. The tool shows both so you can move between them.
Does it handle the week form?
Yes. P4W is four weeks. Strictly the week designator is not meant to be combined with other components, and the tool notes it when your input does combine them, since some parsers reject that.
Privacy & Security
Everything runs in your browser; nothing is uploaded.
How to Use
Paste an ISO 8601 duration to decode it, or fill in the unit fields to build one.
Disclaimer: This tool is provided "as is" without warranty of any kind. Results are for educational and utility purposes.
Related Tools
JSON Formatter
DeveloperFormat and beautify JSON in your browser. Pinpoints syntax errors by line and column, flags unsafe integers, and never uploads your data to a server.
JSON Validator
DeveloperValidate JSON syntax with precise line and column errors, and check documents against a JSON Schema. Runs locally in your browser, nothing uploaded.
Regex Tester
DeveloperTest regular expressions against sample text with live match highlighting, capture groups and flag control. Runs entirely in your browser.