386+ Tools Comprehensive Tools for Webmasters, Developers & Site Optimization

API Response Mocker - Create Mock JSON Responses

API Response Mocker

Create mock API responses with custom status codes, headers, and JSON payloads.

Common: 200 (OK), 201 (Created), 400 (Bad Request), 401 (Unauthorized), 404 (Not Found), 500 (Server Error)

How to Use the API Response Mocker

This tool helps you design and visualize API responses before implementing your backend, making frontend development faster and more independent.

Step-by-Step Instructions:

  1. Choose a status code: Select an appropriate HTTP status code (200 for success, 404 for not found, etc.)
  2. Write your JSON response: Enter the JSON structure you want your API to return
  3. Add custom headers: (Optional) Add headers like Content-Type, Cache-Control, etc.
  4. Generate: Click "Generate Mock Response" to see the formatted result
  5. Copy & use: Copy the response to use in your frontend code or documentation

Example Use Cases:

  • Frontend Development: Build UI components before the backend API is ready
  • Error Handling: Test how your app handles different error responses (400, 401, 500)
  • Documentation: Create example responses for API documentation
  • Contract Testing: Define API contracts between frontend and backend teams
  • Demo & Prototyping: Create realistic mock data for demos and prototypes

Example Mock Responses:

Success Response (200):
{
  "status": "success",
  "data": {
    "id": 123,
    "username": "johndoe",
    "email": "john@example.com",
    "created_at": "2024-01-15T10:30:00Z"
  }
}
Error Response (404):
{
  "status": "error",
  "error": {
    "code": "NOT_FOUND",
    "message": "User not found",
    "details": "No user exists with ID 999"
  }
}
Validation Error (400):
{
  "status": "error",
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Invalid request data",
    "fields": {
      "email": "Invalid email format",
      "password": "Password must be at least 8 characters"
    }
  }
}

Common HTTP Status Codes:

  • 200 OK: Request succeeded
  • 201 Created: Resource created successfully
  • 204 No Content: Success with no response body
  • 400 Bad Request: Invalid request data
  • 401 Unauthorized: Authentication required
  • 403 Forbidden: Access denied
  • 404 Not Found: Resource doesn't exist
  • 500 Internal Server Error: Server error

Related Tools: