---
title: "normalize"
description: "The vector scaled to length 1."
group: "space"
groupTitle: "Shapes, frames & warps"
categoryId: "math"
categorySlug: "math"
categoryTitle: "Math"
kind: "function"
sourceUrl: "https://github.com/shader-effects-inc/shaders/blob/main/packages/core/src/std/math.ts#L351"
---

# normalize

The vector scaled to length 1.

```ts
normalize(v: Val): Expr
```

Import `math` from `shaders/std` and use `math.normalize`.

A zero vector gives NaN, so keep the input non-zero.

## Parameters

| Name | Type | Notes |
|---|---|---|
| `v` | `Val` |  |

## Example

```ts
const dir = normalize(sub(params.uniforms.target, params.uniforms.origin))
```

## See also

- [`length`](/docs/primitives/math/length) — The length of a vector.
- [`dot`](/docs/primitives/math/dot) — The dot product of two vectors.

## Used by

[Crystal](/docs/components/crystal), [Frost](/docs/components/frost), [Goo](/docs/components/goo), [Hologram](/docs/components/hologram), [Holographic](/docs/components/holographic), [Irradiance](/docs/components/irradiance), [Plastic](/docs/components/plastic), [ReactionDiffusion](/docs/components/reactiondiffusion), [Voxels](/docs/components/voxels), [Water](/docs/components/water)