Your API returns 0.375. The design mock says "⅜". The recipe your app is scaling says 0.666 cups but the user owns measuring cups marked in quarters. Somewhere between the machine world and the human world, decimals have to become fractions — and every developer, designer, or DIYer hits this gap eventually.
The good news: the conversion is a 3-step mechanical process. No memorization, no algebra tricks. Here's the whole thing.
The method in 30 seconds
- Write the decimal over its place value. One decimal place → over 10. Two → over 100. Three → over 1000.
- Find the greatest common divisor of the top and bottom numbers.
- Divide both by the GCD. That's your simplified fraction.
That's it. 0.75 → 75/100 → GCD(75, 100) = 25 → 3/4. Everything below is just this pattern applied to different numbers.
Why the place-value trick works
A decimal is already a fraction in disguise. "0.75" literally means "75 hundredths" — the digits after the point tell you the denominator directly. You're not computing anything in step 1; you're just rewriting notation.
The only real math is step 3: simplification. And even that has a boringly reliable procedure — divide both numbers by 2, 3, 5, whatever divides them evenly, until nothing divides both. What survives is the GCD.
Worked examples (the ones you'll actually look up)
0.5 → 5/10 → GCD(5,10) = 5 → 1/2
0.75 → 75/100 → GCD(75,100) = 25 → 3/4
0.125 → 125/1000 → GCD(125,1000) = 125 → 1/8
0.6 → 6/10 → GCD(6,10) = 2 → 3/5
1.25 → separate the whole number: 1 + 0.25 → 25/100 → GCD(25,100) = 25 → 1 1/4
Notice the pattern: the denominator is always 10, 100, or 1000 at first, then it collapses. If you remember only one thing, remember this: count the decimal places, that's your zeros.
The one case that breaks the pattern
Repeating decimals — 0.333…, 0.1666… — never terminate, so they can't be written over a power of 10. 0.333… = 1/3, but getting there needs a different technique (multiply by 10, subtract, solve). In practice, this is exactly where you stop doing it by hand and use a tool.
A 10-second demo: the tool I built (disclosure: it's mine)
Full disclosure: I built this. It's one of 30 free utilities on ToolkitLoop, and it's 100% client-side — your numbers never leave the browser.
Type a decimal and you get the simplified fraction instantly, with each simplification step shown so you can verify the math instead of trusting a black box:
It also handles the awkward cases — repeating decimals, mixed numbers like 1.25, and longer decimals where the GCD isn't obvious:
Try it here: decimal to fraction converter
The cheat sheet worth bookmarking
These ten cover nearly every real-world lookup — recipes, tape measures, CSS values, grades:
| Decimal | Fraction |
|---|---|
| 0.125 | 1/8 |
| 0.2 | 1/5 |
| 0.25 | 1/4 |
| 0.333… | 1/3 |
| 0.375 | 3/8 |
| 0.5 | 1/2 |
| 0.625 | 5/8 |
| 0.666… | 2/3 |
| 0.75 | 3/4 |
| 0.875 | 7/8 |
If you're building anything that displays measurements to humans — a recipe scaler, a dashboard, a CNC readout — keep this table one keystroke away.
Bonus: the same method in 8 lines of JavaScript
Since this is dev.to, here's the whole 3-step method as code — place value, GCD via Euclid's algorithm, simplify:
function gcd(a, b) { return b ? gcd(b, a % b) : a; }
function decimalToFraction(d) {
const places = (d.toString().split('.')[1] || '').length;
const denom = 10 ** places; // step 1: place value
const num = Math.round(d * denom);
const g = gcd(num, denom); // step 2: GCD
return `${num / g}/${denom / g}`; // step 3: simplify
}
decimalToFraction(0.75); // "3/4"
decimalToFraction(0.125); // "1/8"
Caveat: this handles terminating decimals only — same as the manual method. Repeating decimals and floating-point dust (looking at you, 0.1 + 0.2) need a tolerance-based approach, which is exactly why the browser tool linked above exists: it shows the steps so you're never debugging a black box.
The takeaway
Decimals come from machines. Fractions come from humans. Converting is a 3-step translation: place value, GCD, simplify. For one-off conversions, do it by hand; for real work, bookmark the tool.
What's the weirdest decimal-to-fraction conversion you've had to do in a project? I'm curious where this actually shows up outside school math — drop it in the comments.


Top comments (1)
i use fraction.js to avoid floating‑point surprises and force rounding to the nearest 1/8 for UI labels
have you run into edge cases with recurring decimals like 1/3?