Welcome to the MongoDB ObjectId Tools! This project provides two simple yet powerful tools for working with MongoDB ObjectIds:
- ObjectId Decoder: Decode a MongoDB ObjectId to reveal its underlying components.
- ObjectId Encoder: Generate a valid MongoDB ObjectId by specifying its components.
MongoDB uses ObjectIds as unique identifiers for documents within collections. These 12-byte values are typically composed of:
- A 4-byte timestamp (in seconds since the Unix epoch)
- A 3-byte machine identifier
- A 2-byte process identifier
- A 3-byte counter
This project provides an interactive way to both decode and encode MongoDB ObjectIds, making it easier to understand and manipulate these identifiers.
- ObjectId Decoder: Input a MongoDB ObjectId and decode it to extract the timestamp, machine identifier, process identifier, and counter.
- ObjectId Encoder: Generate a MongoDB ObjectId by specifying the timestamp, machine identifier, process identifier, and counter.
To use this project, simply clone the repository and open the index.html
file
in your browser. No additional setup or dependencies are required.
git clone https://github.com/ExZyle/mongo-objectid-tools.git
cd mongo-objectid-tools
- Navigate to the decoder.html page.
- Enter a valid MongoDB ObjectId in the input field.
- Click "Decode" to reveal the decoded components, including the timestamp (in both UTC and local time), machine identifier, process identifier, and counter.
- Navigate to the encoder.html page.
- Provide the following details:
- Timestamp: Select the date and time (local time zone).
- Machine Identifier: Enter a 6-character hexadecimal string.
- Process Identifier: Enter a number between 0 and 65535.
- Counter: Enter a number between 0 and 16777215.
- Click "Generate ObjectId" to create and display the ObjectId based on the provided inputs.
The project consists of three main HTML files:
index.html
: The landing page with instructions and links to the tools.decoder.html
: The page for decoding MongoDB ObjectIds.encoder.html
: The page for encoding MongoDB ObjectIds.
mongo-objectid-tools/
│
├── index.html
├── encoder.html
├── decoder.html
└── README.md
Contributions are welcome! If you'd like to improve this project, please fork the repository and create a pull request. For major changes, please open an issue first to discuss what you'd like to change.
- Fork the project
- Create your feature branch (git checkout -b feature/AmazingFeature)
- Commit your changes (git commit -m 'Add some AmazingFeature')
- Push to the branch (git push origin feature/AmazingFeature)
- Open a pull request
This project is licensed under the MIT License. See the LICENSE file for details.