ninIdentity

Mock Jutsu HOW-TO | EN

Generating realistic UK National Insurance Numbers is a critical requirement for developers building financial, healthcare, or government-related applications. The nin function within the mock-jutsu library provides a streamlined way to produce high-quality mock data that adheres to the official formatting standards used by HM Revenue and Customs. By using this specialized identity tool, engineers can bypass the risks associated with using real sensitive information while ensuring their systems can handle identity-related inputs effectively and securely.

The mock-jutsu implementation follows the standard NIN format, which typically consists of two prefix letters, six digits, and a single trailing letter, often represented as "AB 12 34 56 C." The algorithm strictly observes the specific rules governing these characters, such as ensuring the prefix does not include restricted letters like D, F, I, Q, U, or V, and that the suffix remains within the valid A through D range. This level of precision ensures that the generated test data passes front-end validation patterns and back-end database constraints, providing a seamless testing experience for QA engineers and developers alike.

In terms of practical testing scenarios, the nin generator is indispensable for stress-testing payroll processing systems, verifying user registration flows for UK residents, and validating complex data migration scripts. Having access to diverse, valid-looking test data allows software teams to identify edge cases in string parsing and storage without compromising data privacy. Whether you are performing manual checks via the CLI or automating high-concurrency load tests in JMeter, the library ensures your identity fields are populated with consistent and structurally sound information that mimics real-world production environments.

Integrating this functionality into your modern development workflow is remarkably simple across various environments. Developers can invoke the function directly in Python using the jutsu.generate('nin') method, while performance testers can leverage the JMeter plugin with the ${__mockjutsu(nin,)} syntax. For quick one-off needs or shell scripting, the command-line interface offers a rapid generation path via mockjutsu generate nin. By incorporating mock-jutsu into your CI/CD pipeline, you ensure that your application remains compliant with data protection regulations like GDPR while maintaining the highest standards of software quality and reliability.

CLI Usage
mockjutsu generate ninmockjutsu bulk nin --count 10mockjutsu export nin --count 10 --format jsonmockjutsu export nin --count 10 --format csvmockjutsu export nin --count 10 --format sql# --mask: regulation-compliant output (PCI DSS / GDPR / KVKK)mockjutsu generate nin --maskmockjutsu bulk nin --count 5 --mask
Python API
from mockjutsu import jutsujutsu.generate('nin')jutsu.bulk('nin', count=10)jutsu.template(['nin'], count=5)# mask=True: regulation-compliant outputjutsu.generate('nin', mask=True)jutsu.bulk('nin', count=5, mask=True)
JMeter
${__mockjutsu_identity(nin)}# JMeter Function: __mockjutsu_identity# Parameter 1: nin# Parameter 2: (not required for this function)# Add 'mask' keyword to get a regulation-compliant masked value${__mockjutsu_identity(nin,mask)}
REST API
GET /generate/nin# → {"type":"nin","result":"...","status":"ok"}GET /bulk/nin?count=10POST /template {"types":["nin"],"count":1}# mask=true: regulation-compliant outputGET /generate/nin?mask=trueGET /bulk/nin?count=5&mask=true

Parameters

Parameter Values Description
--mask true | false Return a regulation-compliant masked value (PCI DSS, GDPR, KVKK…)

Other Languages