Vector Normalization

L2-normalize a vector to unit length.

FreeNo accountOn your device

Runs in your browser. How to verify

Loading tool…

About this tool

Enter a vector and get it scaled to length 1 by dividing every component by the L2 norm. (3, 4) has norm 5, so it becomes (0.6, 0.8). Normalised vectors let a dot product equal cosine similarity.

How to use

1
Step 1
Enter the vector, comma separated.
2
Step 2
Press Calculate.
3
Step 3
Copy the unit vector.

How it works

v̂ = v / ‖v‖₂. The direction is unchanged and the length becomes 1. Vector databases often store normalised embeddings so that inner product search gives the same ranking as cosine similarity.

v̂ = v / ‖v‖₂

Worked example

The 3-4-5 vector

Input
3, 4
Output
0.6, 0.8 (original norm 5, new norm 1)
Walkthrough
√(3² + 4²) = 5, then 3/5 = 0.6 and 4/5 = 0.8.

Limitations

  • A zero vector cannot be normalised.
  • L2 normalisation only; no L1 or max normalisation.
  • Output is rounded to six decimals.

Questions

How do I normalize a vector?
Divide each component by the vector's length. The tool does this and shows both norms.
Why normalise embeddings?
It makes dot product and cosine similarity equivalent and puts all vectors on a comparable scale.
What is a unit vector?
A vector with length 1.
Does normalising change direction?
No, only the length changes.

Features

  • L2 normalization
  • Before and after norms
  • Runs in your browser

Related resources

Guides and videos from around the web—opens on YouTube or the publisher’s site.

  • TensorFlow 2.0 Complete Course

    freeCodeCamp.org

    Practical ML stack context next to AI utilities.

    Watch on YouTube
  • Machine Learning for Everybody

    freeCodeCamp.org

    Accessible ML survey for AI calculator and metric tools.

    Watch on YouTube