π Swagger-like Analyzer for MongoDB (Mongoose) Models
Automatically analyze, visualize, and document your MongoDB models in a Node.js + Express application.
mongodb-models-visualizer is a developer tool that introspects your Mongoose models and provides:
- List of all registered models
- Schema fields with types & validations
- Model relationships (
ref) - Collection names
- Optional sample documents
- Swagger-like web UI
- JSON APIs for documentation & automation
Think of it as Swagger, but for MongoDB schemas.
- Node.js β₯ 16
- Express β₯ 4
- Mongoose β₯ 6
npm install mongodb-models-visualizeror
yarn add mongodb-models-visualizerimport express from 'express'
import mongoose from 'mongoose'
import { modelAnalyzer } from 'mongodb-models-visualizer'
const app = express()
mongoose.connect(process.env.MONGO_URI)app.use(
'/models-analyzer',
modelAnalyzer({
mongoose
})
)app.listen(3000, () => {
console.log('Server running on http://localhost:3000')
})Navigate to http://localhost:3000/models-analyzer
GET /models-analyzer/api/models
Example Response:
[
{
"name": "User",
"collection": "users",
"fields": [
{
"name": "email",
"instance": "String",
"required": true,
"enum": [],
"ref": null
}
]
}
]GET /models-analyzer/api/models/:modelName
modelAnalyzer({
mongoose, // required
sampleDocs: true, // optional (default: false)
auth: false // optional (default: false)
})| Option | Type | Description |
|---|---|---|
| mongoose | Object | Mongoose instance |
| sampleDocs | Boolean | Include sample documents |
| auth | Boolean | Enable auth middleware |
Do NOT expose this endpoint publicly without authentication.
Example using basic auth:
import basicAuth from 'express-basic-auth'
app.use(
'/models-analyzer',
basicAuth({
users: { admin: 'password' },
challenge: true
}),
modelAnalyzer({ mongoose })
)- Scans all registered Mongoose models
- Extracts schema metadata
- Parses fields, types, refs, and indexes
- Builds structured JSON output
- Serves data via API & UI
- Model scanner
- Schema parser
- JSON APIs
- Swagger-like UI
- Relationship graph
- Index analyzer
- Performance suggestions
- Migration hints
- CLI support
- Fastify & NestJS adapters
Contributions are welcome!
git clone https://github.com/Hibbanur-Rahman/mongodb-visualizer.git
cd mongodb-visualizer
npm install
npm run buildFeel free to open issues or pull requests π
MIT License Β© 2026
- MongoDB has no built-in schema visualization
- Helps onboarding new developers
- Great for documentation & debugging
- Inspired by Swagger & Prisma Studio


