Where to see a 20-digit security code on Xiaomi: all ways of 2026

Have you encountered a request for a 20-digit security code when unlocking a bootloader, resetting a Mi Account, or restoring access to a Xiaomi device?This unique identifier is a key element of data protection on the brand's smartphones, but its location is not always obvious. IMEI or serial number, the security code is not printed on the box and is not duplicated in standard settings.

In this article, we will discuss all the official and hidden ways to find 20-digit code on Xiaomi, Redmi and other devices. POCO — From the new 2026 models to the older versions MIUI 10.We will pay special attention to situations where the phone is locked and access to settings is limited, and we will also explain why this code may be required even if you do not plan to unlock the bootloader.

We warn you right away: the security code is tied to the hardware identifier of the device and cannot be regenerated - it can only be extracted from the system or obtained through official Xiaomi channels.

What is Xiaomi’s 20 digit security code and why you need it?

The 20-digit code (sometimes mistakenly referred to as the “unlock code” or “Mi Account password”) is a unique alphanumeric identifier that Xiaomi assigns to each device to protect against unauthorized access.

  • 🔓 Unlock the bootloader before running custom software or obtaining root rights. Without this code, the official Mi Unlock Tool will not allow you to continue the process.
  • 🔄 Restore access to Mi Account when password is lost if two-factor authentication is enabled.
  • 📱 Reset activation after hard reset if the device was linked to the account.

It is important to understand that this code does not replace:

  • 🚫 Password from Mi Account (this is a separate combination you set when registering).
  • 🚫 PIN-screen-locking code.
  • 🚫 IMEI serial number (SN) device.

Starting with MIUI 12, Xiaomi has tightened security policies: code is now required for even some official operations, such as flashing through Fastboot or restoring a backup.

⚠️ Note: If you buy Xiaomi from hand, be sure to ask the seller for a screenshot with a security code (you can cover some of the characters). Without it, you will not be able to unlock the bootloader or restore access when you block Mi Account.

Where to look for a 20-digit code on a working phone

If you have a smartphone Xiaomi/Redmi/POCO It's on and you have access to settings, and you can find the security code in a number of ways.

Method 1: Through Mi Account Settings

This is the official method that works on all devices with MIUI 11 and newer:

  1. Open the Settings. → Xiaomi Account (or Mi Account).
  2. Slip on the profile avatar at the top of the screen.
  3. Choose Security → Device security code.
  4. The system may request confirmation by SMS account-password.

The code will be displayed in format XXXX-XXXX-XXXX-XXXX-XXXX (20 characters broken into blocks. You can copy it or take a screenshot. Some firmware may have code hidden under the button Show code.

Method 2: Using the About Phone Menu

Alternative path (works on the MIUI 12–14):

  1. Go to Settings → About the phone → All the characteristics.
  2. Put a few times on the version. MIUI, Notice: “You have become a developer».
  3. Return to the main settings menu and open Additional → for developers.
  4. Scroll down to the Debugging block and select the Device Security Code.

If you don't have a point, your firmware version doesn't support this method. MIUI last-minute.

Make sure your phone is connected to the internet.

Battery charge of at least 50%

Turn it off. VPN (It can block access to Xiaomi servers)

Have a password from your Mi Account

-->

Method 3: Through the Security App

On some models (for example, Xiaomi 13 Pro or Redmi Note 12) the code can be found in the proprietary application:

  1. Open the Security app (the shield icon).
  2. Go to the Mi Account or Account section.
  3. Select Device Management → Current device.
  4. Slip on the item Security Code or Device Identifier.

If the app is missing, you can download it from the Mi App Store (not to be confused with Google Play!).

How to find out the code if the phone is locked or not turned on

The situation is complicated if the device is blocked by a pattern lock, PIN-It's not coded or responsive to on, and in this case, the standard methods won't work, but there are workarounds.

Method 1: Through Fastboot Mode (ADB)

If the phone is turned on but locked by the lock screen, you can try extracting the code through the lock screen. ADB (Android Debug Bridge:

  1. Connect your phone to your PC via USB.
  2. Keep Volume down. + Meals to enter the Fastboot.
  3. On your computer, open the command line and type: fastboot oem device-info
  4. In the conclusion, find the Security Code line: this is your 20-digit code.

⚠️ Limitation: This method only works if the mode has been previously activated OEM Unlock in developer settings. On new devices (Xiaomi 14, Redmi Note 13), Xiaomi blocks access to code through Fastboot.

Method 2: Through the official Xiaomi website

If you have access to the Mi Account, you can request the code on the site:

  1. Go to account.xiaomi.com and log in.
  2. Select a locked device in the list of tied devices.
  3. Press Device Control. → Request a security code.
  4. Confirm the request through SMS email.

The code will come to the post office or in SMS Note: Xiaomi may request additional data (e.g. purchase check) to confirm ownership.

What to do if Xiaomi refuses to issue a code?
If the support service declined the request, try: 1. Provide a photo of the box with IMEI (2. Send a check or warranty card (even if the warranty expires). 3. Contact an authorized service center with a passport. Without confirmation of purchase, the chances of obtaining the code are minimal - Xiaomi strictly monitors the resale of devices.

Method 3: Through a service center

If the phone doesn’t turn on at all (for example, after a failed firmware), the only legal way to do this is to contact a Xiaomi authorized service center.

  • 📄 Passport (for proof of identity).
  • 📦 Phone box (with matching phone) IMEI).
  • 💳 Check or warranty card (if any).

The service center can extract the code through special software (Mi Authorized Tool), but only if the device is not blacklisted (for example, after theft), the cost of the service is from 1000 to 3000 rubles depending on the model.

⚠️ Warning: Don't trust "masters" who promise to extract code in 5 minutes through "secret commands." 99% chance they're scammers who either steal data from a phone or block it permanently. Officially, the code can only be obtained through Xiaomi or a service center.

Yeah, when you unlock the loader.|Yes, when you restore your Mi Account|No, but I know he is.|What is it?-->

How to Protect Your Security Code from Leakage

A 20-digit code is like a master key from your Xiaomi, and if it gets into the wrong hands, attackers can:

  • 🔓 Unlock the bootloader and install spyware.
  • 📱 Reset your Mi Account and sell your phone.
  • 💳 Access payment data (if cards are tied).

To avoid problems, follow the rules:

Action.RiskHow to protect yourself
Storing code in the cloud (Google Drive, mail)Leaked account hackingSave the code offline (record in a notebook, flash drive)
Transfer of code when selling a phoneThe customer can unlock the bootloader without you.Remove the device from your Mi Account before transfer
Photographing code and sending messengersScreenshot interception by viruses or hackersUse encryption applications (such as Signal)
Entering code on suspicious sites ("code generators")Phishing and data theftUse only official Xiaomi channels

If you suspect that the code may have been accessed by third parties, immediately:

  1. Change the password from the Mi Account.
  2. Untie the device in your account settings (account.xiaomi.com) → Device management).
  3. Enable two-factor authentication (SMS + email).

💡

If you are a frequent flasher, create a separate Mi Account specifically to unlock the downloaders.

Frequent errors when working with security code

Even experienced users sometimes make mistakes that lead to locking the device, and here are the most common:

Error 1: Misunderstands security code with Mi Account unlock code

It's different.

  • 🔐 Device security code - 20 characters, tied to "iron", needed to unlock the bootloader.
  • 🔑 Mi Account unlock code – 6-8 digits, comes in SMS password-reset.

If you enter a security code instead of an account unlock code (or vice versa), the system will block attempts for 24-72 hours.

Error 2: Entering code with spaces or hyphens

The code must be entered in a single form, without separators.

  • ❌ Wrong: ABCD-EFGH-IJKL-MNOP-QRST
  • ✅ Right: ABCDEFGHIJKLMNOPQRST

Many users copy code from messages or screenshots where it is displayed with hyphens and paste it without editing, resulting in the Mi Unlock Tool producing an Invalid code error.

Error 3: Attempting to unlock on unofficial firmware

If you have already flashed your phone with custom firmware (like LineageOS or Pixel Experience), the official Mi Unlock Tool will not be able to recognize the security code.

  1. Back on the stock firmware. MIUI via Fastboot.
  2. Sign in to the Mi Account.
  3. Only then do you request to be unlocked.

On some forums, it is recommended to “reset” the unlock counter through ADB, But it only works on older devices (up to Xiaomi Mi 9).

1. The code is entered without spaces and in the upper case.

2.The device is tied to the Mi Account for at least 72 hours.

3. In the settings enabled OEM Unlock and USB Debugging.-->

Alternative ways to unlock without code

If you lose the code and can’t recover it, there are a few legal (and not so) ways to get around the lock, and most of them will only work on older models (Xiaomi Mi 8, Redmi Note 7 and earlier).

Method 1: Exploitation through EDL-regime

EDL (Emergency Download Mode is a service mode that allows you to stitch the device around the locks:

  • 🖥️ PC with Qualcomm drivers installed.
  • 🔌 Cable USB Type-C (preferably original).
  • 📁 Firmware in.mbn format for your model.

Instructions:

  1. Turn off the phone.
  2. Hold the Loud up. + Loudness down + Food (on some models you need to close contacts on the board).
  3. Connect to a PC – the device will be defined as Qualcomm HS-USB QDLoader 9008.
  4. Run the Mi Flash Tool and run the stock firmware.

⚠️ Risks:

  • On New Devices (Snapdragon) 8 Gen 2/3) Xiaomi is blocking EDL login.
  • The wrong firmware can turn your phone into a brick.

Method 2: Appealing for Xiaomi with proof of purchase

If you have a check, a warranty card or a box of IMEI, You can try writing support:

  1. Create a ticket at support.xiaomi.com.
  2. Attach a photo of documents confirming the purchase.
  3. Specify the reason (e.g., “the security code lost after resetting”).

Response time is 3 to 10 days, and the odds are higher if you bought the device less than a year ago.

Method 3: Use of vulnerabilities in older versions MIUI

On the firmware MIUI 10–11 exploits exist that allow you to bypass the code request ADB. For example:

adb shell


su




setprop persist.vendor.unlock 1

But after MIUI 12 Xiaomi has closed most of these vulnerabilities:

  • 📱 Xiaomi Mi A1/A2 (Android One).
  • 📱 Redmi 5/5 Plus with firmware up to 2019 year-end.
  • 📱 POCO F1 on MIUI 9–10.

⚠️ Note: Using unofficial unlock methods can lead to a ban Mi Account. Xiaomi blocks accounts that suspect exploits, without the right to restore.

FAQ: Answers to Frequent Questions

Can you create a 20-digit code yourself?
No, the code is generated from hardware data (IMEI, The serial number, the chipset data, and it can't be generated software.
Why does Xiaomi require code even for official firmware?
This is a measure of protection against theft and illegal resale, and since 2020 Xiaomi has tightened its policies following a wave of device thefts in Europe and Asia.
Can I unlock a bootloader without a code after 720 hours of waiting?
It used to be, but with MIUI 13 even after waiting, you need to enter a 20-digit code. 720 hours (30 days) are now only needed to re-link your account.
What if the code is not suitable (Invalid code)?
Check: Code is entered without spaces or hyphens. Device is tied to Mi Account for at least 30 days. You use the latest version of Mi Unlock Tool. If the error persists, contact the logs for support (MiUnlock.log).
Where is the security code stored in the Android file system?
The code is not stored as a text file. It's written in a protected area. /dev/block/bootdevice and is only retrieved through official channels or service utilities.