---
title: "Convert a number to a string with a fixed number of decimal places without trailing zeros"
description: "Format numbers to a fixed decimal precision without trailing zeros in TypeScript."
date: "2025-10-02"
tags: ["typescript","math","formatting","frontend"]
canonical: "/snippets/typescript/number/to-fixed-without-zero"
---

import { Code } from '@astrojs/starlight/components'
import Source from './to-fixed-without-zero.ts?raw'

## Convert a number to a string with a fixed number of decimal places without trailing zeros

<Code code={Source} lang="ts" title="to-fixed-without-zero.ts" wrap />
