The command line version of Mi Unlock Tool is a great alternative. Open source and written in Python this tool does everything the official tool does but is not limited to Windows. You can run it on Windows, macOS or Linux. It also lets you login via email instead of SMS which gets rid of OTP problems permanently. In this post, we will share the latest Mi Unlock Tool Command Line Version with a guide.
If you have ever tried unlocking the bootloader on a Xiaomi phone, you already know the pain. The official Mi Unlock Tool only runs on Windows, and its SMS login system is just unreliable. You request an OTP, wait forever, and by the time it arrives, it has already expired. Do that a few times, and you will start looking for alternatives. And here is the alternative to the official Mi bootloader unlock tool – Mi Unlock Tool Command Line Version.
What is Mi Unlock Tool CLI
The Command Line Version of Mi Unlock Tool is a Python program. It grabs encryptData token that unlocks your device bootloader. Instead of a graphical user interface, you operate with a terminal. The tool connects to Xiaomi servers and handles authentication; it communicates in fastboot mode to complete unlocking. The official tool from Xiaomi runs only on Windows. This version works on MacBooks and Linux.
Features
- Runs on Windows, macOS, and Linux – no virtual machine needed just to unlock a bootloader
- Login through SMS and email. The email option saves you if you keep getting delayed OTP messages
- Saves your login session so you do not have to sign in again every time you use it
- Manual region configuration – switch data center zones when auto detection fails
- Open source code so anyone can inspect or improve it
| Feature | Mi Unlock Tool CLI | Official Mi Unlock Tool |
|---|---|---|
| Platform support | Windows, macOS, Linux | Windows only |
| Login methods | SMS + Email | SMS only |
| Session saving | Yes | No |
| Region config | Automatic + Manual | Automatic only |
| Open source | Yes | No |
Supported Devices
- All Xiaomi, Redmi, and POCO phones
- Devices running MIUI and HyperOS
- Both A-only and A/B slot devices
- The tool follows the same official unlocking process from Xiaomi, so compatibility is the same as the official tool.
Requirements
- A Windows, macOS, or Linux PC with internet access
- Python 3 is installed on your system
- pip package manager
- A Xiaomi device with developer options enabled
- Your Mi account added in Settings > Additional Settings > Developer Options > Mi Unlock Status
- USB drivers installed on Windows (or fastboot working on Linux/macOS)
- Xiaomi Community permission if you are on HyperOS (required by Xiaomi, not the tool itself)
- One thing to keep in mind: this tool does not bypass the waiting period. You still have to wait 168 hours (7 days) on MIUI or 72 hours (3 days) on HyperOS before you can unlock. The tool just gives you a smoother way to go through the same official process.
Changelogs
v1.7.3
- minor improvements: support python -m miunlock when entry point is unavailable
v1.6.9
- Improved error handling
- Enhanced login flow
v1.6.0
- Added proper data center zone configuration
- Better logging output
Download Mi Unlock Tool Command Line Version
Download Mi Unlock Tool Command Line Version 1.7.3 from the official GitHub page.
Mi Unlock Tool CLI Installation Guide
Step 1 – Install Python
If you do not have Python installed, grab it from python.org. On Windows, make sure you check the โAdd Python to PATHโ option during installation. On Linux, use your package manager (apt, dnf, pacman). On macOS, use Homebrew or the official installer.
Step 2 – Create a virtual environment (recommended)
Open your terminal and run:
python3 -m venv miunlock-env
Step 3 – Activate the environment
On Linux and macOS:
source miunlock-env/bin/activate
On Windows with PowerShell:
miunlock-env/bin/Activate.ps1
On Windows with CMD:
miunlock-env/bin/activate.bat
Step 4 – Install the tool
pip install miunlock
That is it. The tool is now ready on your system.
How to Use Mi Unlock Tool CLI
Before you start, take a full backup of your device. Unlocking the bootloader wipes all your data, and there is no reversing the process once it starts.
Step 1 – Add your Mi account on the phone
Go to Settings > Additional Settings > Developer Options > Mi Unlock Status. Tap โAdd account and deviceโ and sign in with the same Mi account you plan to use on the tool.
Step 2 – Boot your phone into fastboot mode
Power off the device. Press and hold Volume Down + Power buttons until you see the fastboot screen with the MI bunny logo.
Step 3 – Connect the phone to your PC
Plug it in with a USB cable. On Windows, make sure the drivers are installed properly. On Linux, run fastboot devices to confirm your device shows up.
Step 4 – Run the tool
In your terminal, type:
miunlock
The tool will ask how you want to log in. Pick SMS or email. If you choose email, the verification code arrives in your inbox almost instantly. No more waiting for late OTP messages.
Step 5 – Follow the prompts
Complete the login and the tool checks your device status. If this is your first time, it will tell you how many hours you still need to wait. There is no shortcut for this.
Step 6 – Come back after the waiting period
Once the waiting time is over, connect your phone again, run miunlock, log in, and let the tool finish. Your device restarts, data gets wiped, and the bootloader is unlocked.
Fix Error Code 20045
If you get error 20045 with a message that says โPlease use the common user tool on the official website,โ try forcing the global region:
python3 MiUnlockTool.py global
This manually sets the data center zone and normally fixes the issue.


