Validate Finnish VAT Numbers (ALV, Y-tunnus) in Node.js

2 Dec 2026

Validate Finnish VAT Numbers (ALV, Y-tunnus) in Node.js

Finland is the easy case in the Nordics. A Finnish VAT number, the ALV-tunniste, is FI plus the company’s business ID, the Y-tunnus, with the hyphen dropped. There is no extra suffix and, unlike Sweden, no personal ID hidden inside it. Strip the hyphen, check the format, then let VIES decide. The register data on top is optional, and a VIES outage is not a verdict. This post covers the Node.js side. For the endpoint’s general behaviour see the Finland VAT API reference, and for a one-off lookup use the Finnish VAT checker.

What a Finnish VAT number looks like

A Finnish VAT number is FI followed by eight digits. The eight digits are the Y-tunnus without its hyphen: seven digits, then a check digit.

  • FI – country code
  • NNNNNNN – seven digits of the business ID
  • N – the last digit of the Y-tunnus, a check digit

Vero’s guidance shows the construction: a Y-tunnus of 0765432-1 gives the VAT number FI07654321. (That number is only an illustration of the pattern; it doesn’t pass the check digit in Step 2.) The regex vatnode uses is ^FI\d{8}$ – ten characters, no more. The national tax ID overview shows the same thing: the VAT suffix and the national ID are the same eight digits, with the hyphen in one and without it in the other.

Step 1: format validation

As with the other guides in this series, decide up front which mode your validator runs in:

const FI_VAT_PATTERN = /^FI\d{8}$/

function normaliseFinnishVatId(
  input: string,
  opts: { mode?: 'strict' | 'lenient' } = {}
): string | null {
  let cleaned = input.replace(/[\s.\-]/g, '').toUpperCase()
  // Lenient mode: accept a bare Y-tunnus, with or without the hyphen
  if (opts.mode === 'lenient' && /^\d{8}$/.test(cleaned)) {
    cleaned = `FI${cleaned}`
  }
  return FI_VAT_PATTERN.test(cleaned) ? cleaned : null
}

// Strict (default) — API consumers should send a fully-qualified ID
normaliseFinnishVatId('FI 0765432-1') // → 'FI07654321'
normaliseFinnishVatId('0765432-1') // → null

// Lenient — for checkout forms where people paste their Y-tunnus
normaliseFinnishVatId('0765432-1', { mode: 'lenient' }) // → 'FI07654321'
normaliseFinnishVatId('FI0765432', { mode: 'lenient' }) // → null (seven digits)

Stripping the hyphen matters here: Finnish companies print their Y-tunnus as 0765432-1 on invoices and websites, and that is what customers paste. A string that passes FI_VAT_PATTERN is only well-formed input.

Step 2: the Y-tunnus and its check digit

This step is optional local work. The API runs the format check and the VIES call itself, so you can skip it and get a free key instead.

The last digit of a Y-tunnus is a check digit. The published rule is a mod-11 sum over the first seven digits with the weights 7, 9, 10, 5, 8, 4, 2. If the remainder is 0, the check digit is 0. If the remainder is 1, no check digit exists and the number can’t be a Y-tunnus. Otherwise the check digit is 11 minus the remainder.

const YTUNNUS_WEIGHTS = [7, 9, 10, 5, 8, 4, 2]

function hasValidYtunnusCheckDigit(eightDigits: string): boolean {
  if (!/^\d{8}$/.test(eightDigits)) return false
  const sum = YTUNNUS_WEIGHTS.reduce((acc, w, i) => acc + w * Number(eightDigits[i]), 0)
  const remainder = sum % 11
  if (remainder === 1) return false
  const expected = remainder === 0 ? 0 : 11 - remainder
  return expected === Number(eightDigits[7])
}

hasValidYtunnusCheckDigit('12345678') // → false (sum 153, remainder 10, expected 1, got 8)
hasValidYtunnusCheckDigit('11111118') // → false (sum 45, remainder 1, no check digit can exist)

Worked through for 1234567-8: 1·7 + 2·9 + 3·10 + 4·5 + 5·8 + 6·4 + 7·2 = 153. 153 mod 11 is 10, so the check digit should be 11 − 10 = 1. The number ends in 8, so it fails.

Treat it as a typo filter. It catches a mistyped digit before you spend a request. It does not tell you that the business exists or that it is registered for VAT. vatnode doesn’t run this check: a Finnish number that matches the format goes to VIES, which does the actual verification. If you add the filter on your side, show a warning rather than blocking: a false rejection costs you a customer, a false pass costs one request.

Step 3: calling the API

interface VatCheckResponse {
  valid: boolean
  vatId: string
  countryCode: string
  countryName: string
  companyName: string | null
  companyAddress: string | null
  companyRegistrationDate: string | null
  companyForm: string | null
  industryDescription: string | null
  registryCode: string | null
  registryCodeName: string | null
  taxId: string | null
  taxIdName: string | null
  website: string | null
  source: string // 'VIES' on a live check, 'CACHE' when served from cache
  checkId: string
  consultationNumber: string | null
  verifiedAt: string
}

async function checkVat(vatId: string): Promise<VatCheckResponse> {
  const res = await fetch(`https://api.vatnode.dev/v1/vat/${vatId}`, {
    headers: { Authorization: `Bearer ${process.env.VATNODE_API_KEY}` },
  })

  if (!res.ok) {
    const body = await res.json().catch(() => null)
    throw new Error(`vatnode request failed: ${body?.error?.code ?? res.status}`)
  }

  return res.json() as Promise<VatCheckResponse>
}

The interface lists only the fields this post uses; the full response is in the API reference. A response for a registered Finnish limited company looks like this:

{
  "valid": true,
  "vatId": "FI12345678",
  "countryCode": "FI",
  "countryName": "Finland",
  "companyName": "Kuusikko Oy",
  "companyAddress": "TESTIKATU 1, 00100 HELSINKI",
  "companyRegistrationDate": "2014-05-09",
  "companyForm": "Limited company",
  "industryDescription": "Computer programming activities",
  "registryCode": "1234567-8",
  "registryCodeName": "Y-tunnus",
  "taxId": "1234567-8",
  "taxIdName": "Y-tunnus",
  "website": "kuusikko.example",
  "source": "VIES",
  "checkId": "019d2a89-a5d9-7b97-b710-57b84604de2b",
  "consultationNumber": null,
  "verifiedAt": "2026-12-02T08:30:00.000Z"
}

FI12345678 and Kuusikko Oy are invented for this example. The number fails the Y-tunnus check digit on purpose, so it can’t belong to a real business. source reads "VIES" on a live check: VIES decides valid. For Finland registryCode and taxId carry the same value, derived from the VAT number itself, and registryCodeName and taxIdName both return the local name, Y-tunnus. consultationNumber is null because this account has no requester VAT number set. Set one in dashboard Account details and a successful check returns the VIES-issued reference when VIES issues one – a record of the check you made, and one piece of the evidence a supplier may keep when applying the reverse charge or the intra-EU supply exemption. It does not establish that either treatment applies, and it is not tax advice.

Three error codes come back without a verdict on the number. A string that fails the format check is rejected as INVALID_FORMAT (HTTP 400). VIES being unreachable is VIES_UNAVAILABLE (HTTP 503), and a VIES timeout is UPSTREAM_TIMEOUT (HTTP 504). Step 4 shows how to handle the last two.

Step 4: PRH enrichment is not a validity fallback

companyRegistrationDate, companyForm and industryDescription in that response did not come from VIES. They come from PRH, the Finnish Patent and Registration Office, through its open YTJ API. vatnode asks PRH only after VIES has confirmed the number is valid, and only to add fields to that answer. website comes from the same lookup: PRH lists a homepage for some companies, and vatnode returns it lower-cased, trimmed, with no trailing slash and not checked for reachability. It often arrives without https://, so add the scheme yourself and validate before you render it as a link.

What that means in practice:

  • No PRH verdict when VIES is down. When VIES FI is down, the API returns VIES_UNAVAILABLE with HTTP 503. It does not fall back to PRH and synthesise a verdict. PRH is a company register, not a VAT register: a business can have a Y-tunnus without being registered for VAT, and Vero treats the two as different things. Deriving valid from register presence would give false positives at exactly the moment you can least afford one.
  • PRH open data leaves out sole traders. A ‘not found’ from PRH can mean a wrong Y-tunnus or a valid sole trader that the open data doesn’t show, so never read a missing PRH record as a bad number.
  • Enrichment is best-effort and bounded. The PRH call runs after VIES inside the same request with a short timeout, and returns nothing on any error. companyRegistrationDate, companyForm, industryDescription and website can all be null on a valid number. PRH never shows up as the source for a Finnish number: it is "VIES" on a live check and "CACHE" when the answer comes from the cache.
  • Registration date is the trade-register date. vatnode takes the earliest dated trade-register entry for the company, and falls back to the date the business ID was assigned if there is none.
  • Form and industry come in English. PRH publishes descriptions in Finnish, Swedish and English; vatnode returns the English one.
async function validateFinnishVat(vatId: string) {
  const cleaned = normaliseFinnishVatId(vatId)
  if (!cleaned) {
    return { valid: false, error: 'INVALID_FORMAT' as const }
  }

  try {
    const r = await checkVat(cleaned)
    return {
      valid: r.valid,
      name: r.companyName,
      // Optional extras — any of these can be null on a valid number
      registeredOn: r.companyRegistrationDate,
      form: r.companyForm,
      industry: r.industryDescription,
    }
  } catch (err) {
    // checkVat puts the API error code in the message
    if (err instanceof Error && /VIES_UNAVAILABLE|UPSTREAM_TIMEOUT/.test(err.message)) {
      // VIES FI is down. No national register can tell you whether a number is
      // VAT-registered. Keep the status you already have and re-check later.
      return { valid: null, error: 'VIES_DOWN' as const, requiresRecheck: true }
    }
    throw err
  }
}

You don’t need PRH credentials or your own Y-tunnus parsing to get these fields. For how enrichment works across every supported country, see the company data enrichment guide. The Swedish version runs the same flow with a personal-ID catch that Finland doesn’t have.

What to store

Store the cleaned VAT ID, the VIES result, and the PRH fields as optional columns. The Y-tunnus is already part of the VAT ID, so a separate column adds nothing.

CREATE TABLE vat_checks_fi (
  id                uuid PRIMARY KEY DEFAULT gen_random_uuid(),
  vat_id            text NOT NULL,
  valid             boolean,                 -- NULL when VIES was unavailable (no verdict yet)
  vies_status       text NOT NULL,           -- 'OK' | 'VIES_UNAVAILABLE' | 'UPSTREAM_TIMEOUT'
  consultation_no   text,                    -- VIES-issued; set only if a requester VAT is configured
  company_name      text,
  company_address   text,
  registration_date date,                    -- PRH enrichment, nullable
  company_form      text,                    -- PRH enrichment, nullable
  industry          text,                    -- PRH enrichment, nullable
  requires_recheck  boolean NOT NULL DEFAULT false,
  checked_at        timestamptz NOT NULL DEFAULT now()
)

The VAT number itself carries no personal identity code. A sole trader’s name and address are still personal data of a natural person, so keep company_name and company_address only for a defined purpose and retention period.

Common gotchas

  • Reading a passing check digit or a Y-tunnus as VAT registration. Only the VIES answer says that.
  • Dropping the hyphen too late. 0765432-1 fails the regex until you strip it. Normalise before you test.
  • Treating null PRH fields as an error. Enrichment is optional.
  • Rendering website as a link as it arrives. Add the scheme and validate it first.
  • Guessing from the register during a VIES FI outage. Queue a re-check instead.

FAQ

Is a Finnish VAT number the same as the Y-tunnus?

It is built from it. The VAT number is FI followed by the Y-tunnus with the hyphen removed, so 0765432-1 becomes FI07654321. The Y-tunnus only says that a business ID exists. Being registered for VAT is a separate status held at Vero, so a Y-tunnus does not make a valid VAT number.

Why doesn’t PRH tell me whether a Finnish VAT number is valid?

PRH runs the trade register, not the VAT register. A company can be listed there without being VAT-registered, and the open data leaves out sole traders, so ‘not found’ cannot mean ‘invalid’. vatnode asks PRH only after VIES has confirmed the number, and only to add fields to that answer.

Can a valid Finnish VAT number come back without any PRH data?

Yes. Enrichment is best-effort. If PRH has no matching record, or does not answer within the timeout, the VIES answer is returned as it is with the PRH-derived fields empty. Treat those fields as optional and never read an empty one as a problem with the VAT number.

What happens when VIES Finland is unavailable?

The API returns the VIES error (503, or 504 on a timeout) instead of a verdict from a national register. Keep the status you already have for that customer and retry later. An outage is not an invalid number.

Validate Finnish VAT numbers without wiring up PRH yourself

Each Finnish check runs VIES first, then adds PRH data – registration date, company form, industry, homepage – when the register has a record. You can start on the free plan.

Get a free API key · API reference · Finland VAT API reference