npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

needs-visa

v1.0.0

Published

Check whether a passport holder needs a visa to travel between two countries. Based on the Passport Index data (199 countries).

Readme

needs-visa

Instantly check visa requirements between any two countries

CI npm version Coverage Status License: MIT

A zero-dependency npm package that instantly checks visa requirements between any two countries from its bundled dataset of 199 nations. Works offline with no API calls or external dependencies.

Data is sourced from the Passport Index data (MIT).


Table of Contents


Features

  • 🚀 Zero dependencies — No external packages or API calls
  • 🔌 Offline-first — All data bundled, works completely offline
  • Sub-millisecond lookups — Synchronous, pre-bundled visa data
  • 🌍 199 countries — Comprehensive coverage of visa requirements
  • 🤝 TypeScript compatible — Works seamlessly with TypeScript projects

Install

npm install needs-visa

Runtime

This package is written for Node.js 18+ with ES modules and works in both CommonJS and ESM environments. It does not work in browsers (no DOM dependencies, but the bundled JSON data is optimized for Node.js).

TypeScript

This package is written in JavaScript but is fully compatible with TypeScript. Import types if needed:

import { needsVisa } from "needs-visa";

const result = needsVisa({ from: "IN", to: "FR" }); // result is boolean | null

Usage

import { needsVisa } from "needs-visa";

needsVisa({ from: "IN", to: "FR" }); // true  — Indian passport needs a visa for France
needsVisa({ from: "US", to: "FR" }); // false — US passport is visa-free for France
needsVisa({ from: "IN", to: "TH" }); // false — visa on arrival counts as no visa needed
needsVisa({ from: "US", to: "AU" }); // false — eTA only, no visa needed
needsVisa({ from: "IN", to: "AU" }); // true  — e-visa required
needsVisa({ from: "in", to: "fr" }); // true  — codes are case-insensitive

Country codes must be ISO 3166-1 alpha-2 (two-letter codes like US, FR, IN).

Performance: All lookups are synchronous and complete in under 1ms. The visa data is pre-bundled, so no initialization or loading is required.

Return values

| Result | Meaning | | ------- | --------------------------------------------------- | | true | A visa is required (including e-visa) | | false | No visa needed (visa-free, visa on arrival, or eTA) | | null | No data available for this country pair |


API

needsVisa({ from, to })

Returns true, false, or null.

needsVisa({ from: "IN", to: "FR" }); // true
needsVisa({ from: "US", to: "FR" }); // false
needsVisa({ from: "ZZ", to: "FR" }); // null — unknown country

getVisaRequirement({ from, to })

Returns a detailed result object, or null if no data is available.

import { getVisaRequirement } from "needs-visa";

// Visa on arrival
getVisaRequirement({ from: "IN", to: "TH" });
// {
//   from: 'IN',
//   to: 'TH',
//   required: false,
//   requirement: 'visa_on_arrival',
//   description: 'Visa can be obtained upon arrival. No prior embassy visit needed.'
// }

// Visa required
getVisaRequirement({ from: "IN", to: "FR" });
// {
//   from: 'IN',
//   to: 'FR',
//   required: true,
//   requirement: 'visa_required',
//   description: 'A visa is required before travel.'
// }

// No admission
getVisaRequirement({ from: "IL", to: "BN" });
// {
//   from: 'IL',
//   to: 'BN',
//   required: null,
//   requirement: 'no_admission',
//   description: 'Entry is not permitted with this passport.'
// }

Requirement types

| Value | Meaning | | ----------------- | ------------------------------------------------------------ | | visa_free | No visa needed | | visa_on_arrival | Visa obtainable on arrival, no embassy visit needed | | eta | Electronic Travel Authorisation (apply online before travel) | | e_visa | Electronic visa required (apply online before travel) | | visa_required | Visa required from embassy/consulate | | no_admission | Entry not permitted or passport not recognized |


getVisaFreeDestinations(passportCountry)

Returns a sorted array of destination country codes that require no visa. Includes visa-free, visa-on-arrival, and eTA destinations.

import { getVisaFreeDestinations } from "needs-visa";

getVisaFreeDestinations("US");
// ['AU', 'BR', 'CA', 'FR', 'DE', 'GB', 'JP', ...]

getVisaRequiredDestinations(passportCountry)

Returns a sorted array of destinations where a visa is required (including e-visa).

import { getVisaRequiredDestinations } from "needs-visa";

getVisaRequiredDestinations("IN");
// ['AU', 'CN', 'DE', 'FR', 'GB', 'NZ', 'SG', 'US', ...]

Data

Visa requirements are bundled as a static JSON file — no network calls are made at runtime. The data is sourced from the passport-index-data project (MIT license).

To refresh the data to the latest version:

npm run build:data

The data is also automatically refreshed monthly via a GitHub Actions workflow that opens a pull request when upstream data changes.

⚠️ Important: Visa requirements change frequently and vary by individual circumstances (employment, length of stay, purpose, etc.). This package provides general guidance only. Always verify with official government sources (embassy websites, immigration portals) before travelling.


Error handling

Invalid country codes throw a TypeError with a descriptive message:

needsVisa({ from: "INVALID", to: "FR" });
// TypeError: "from" must be a valid ISO 3166-1 alpha-2 country code (e.g. "US", "FR", "IN"). Received: "INVALID"

needsVisa({ to: "FR" });
// TypeError: "from" must be a non-empty string.

Contributing

Found a bug or have a feature request? Please open an issue.

To contribute:

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/your-feature
  3. Commit your changes: git commit -am 'Add feature'
  4. Push to the branch: git push origin feature/your-feature
  5. Open a Pull Request

All tests must pass: npm run validate


License

Licensed under MIT

Data from passport-index-data — also MIT.