Paste as JSON...
The paste as JSON feature provides multiple JSON data processing methods, allowing you to quickly format, compress, escape JSON content, or extract key names from JSON. Whether you need to beautify JSON, compress JSON for transmission, or quickly obtain JSON structure, you can accomplish it easily.
Feature Overview
JSON paste features include the following core operations:
- JSON Formatting: Format compressed JSON into readable multi-line format
- JSON Compression: Compress formatted JSON into a single line, saving space
- JSON Compression and Escape: Compress JSON and escape special characters, suitable for embedding in code or strings
- Extract JSON Keys: Quickly extract all key names from JSON objects
Usage
Basic Operations
- Open DPaste clipboard history (
⌘ + Shift + V) - Find a record containing JSON content
- Right-click the record
- Select "Paste as..." → "JSON Formatting" (or other JSON options)
- Content will be pasted in the converted format to the target location
- Select a record containing JSON in clipboard history
- Use the corresponding shortcut to quickly apply JSON conversion
- Content will be pasted in the converted format
Feature Details
1. JSON Formatting
Format compressed JSON into readable multi-line format, convenient for viewing and editing.
- JSON responses from APIs are in compressed format, need to view structure
- Need to view JSON hierarchy when debugging
- Need to manually edit JSON content
Input (compressed format):
{"name":"DPaste","version":"1.0","features":["clipboard","ocr"],"settings":{"theme":"dark","language":"zh-CN"}}
Output (after formatting):
{
"name": "DPaste",
"version": "1.0",
"features": [
"clipboard",
"ocr"
],
"settings": {
"theme": "dark",
"language": "zh-CN"
}
}
- Copy compressed JSON content
- Find the record in clipboard history
- Right-click and select "Paste as..." → "JSON Formatting"
- After pasting, you'll get formatted JSON
2. JSON Compression
Compress formatted JSON into a single line, removing all whitespace characters and line breaks, saving space.
- Need to use JSON for URL parameters or configuration files
- Reduce JSON file size
- Need single-line format JSON for logging
Input (formatted format):
{
"name": "DPaste",
"version": "1.0",
"features": [
"clipboard",
"ocr"
]
}
Output (after compression):
{"name":"DPaste","version":"1.0","features":["clipboard","ocr"]}
- Copy formatted JSON content
- Find the record in clipboard history
- Right-click and select "Paste as..." → "JSON Compression"
- After pasting, you'll get compressed JSON
3. JSON Compression and Escape
Compress JSON and escape special characters, making it suitable for embedding in code strings or using as string values.
- Need to embed JSON as a string in code
- Need JSON string literals in JavaScript/TypeScript
- Need to escape special characters like quotes, line breaks, etc. in JSON
Input (formatted format):
{
"name": "DPaste",
"description": "A powerful clipboard tool"
}
Output (compressed and escaped):
{\"name\":\"DPaste\",\"description\":\"A powerful clipboard tool\"}
const jsonString = "{\"name\":\"DPaste\",\"description\":\"A powerful clipboard tool\"}";
const data = JSON.parse(jsonString);
- Copy JSON content
- Find the record in clipboard history
- Right-click and select "Paste as..." → "JSON Compression and Escape"
- After pasting, you'll get compressed and escaped JSON string
4. Extract JSON Keys
Quickly extract all key names from JSON objects, convenient for viewing data structure or generating type definitions.
- Need to quickly understand what fields a JSON object contains
- Generate TypeScript interfaces or type definitions
- Analyze API response data structure
- Extract field names for code generation
Input:
{
"name": "DPaste",
"version": "1.0",
"features": ["clipboard", "ocr"],
"settings": {
"theme": "dark",
"language": "zh-CN"
}
}
Output (extracted keys):
name, version, features, settings
For nested objects, you can extract key names from all levels:
Input:
{
"user": {
"name": "John",
"email": "john@example.com",
"profile": {
"age": 30,
"city": "Beijing"
}
}
}
Output:
user, name, email, profile, age, city
- Copy JSON content
- Find the record in clipboard history
- Right-click and select "Paste as..." → "JSON Keys"
- After pasting, you'll get a list of all key names
Practical Use Cases
Scenario One: API Debugging
API responses are usually in compressed format, using JSON formatting can quickly view structure:
1. Copy API response: {"status":200,"data":{"users":[{"id":1,"name":"Alice"}]}}
2. Right-click and select "JSON Formatting"
3. Get readable format:
{
"status": 200,
"data": {
"users": [
{
"id": 1,
"name": "Alice"
}
]
}
}
Scenario Two: Configuration File Processing
Need to compress formatted configuration files for deployment:
1. Copy formatted configuration file
2. Right-click and select "JSON Compression"
3. Get single-line format, easy to store or transmit
Scenario Three: Code Generation
Extract JSON Keys for generating TypeScript interfaces:
1. Copy API response JSON
2. Right-click and select "JSON Keys"
3. Get: status, data, users, id, name
4. Use these key names to quickly generate interface definitions
Scenario Four: String Embedding
Need to embed JSON as a string in code:
1. Copy JSON object
2. Right-click and select "JSON Compression and Escape"
3. Directly paste to string position in code
Notes
JSON Format Requirements
- All JSON operations require input content to be valid JSON format
- If content is not valid JSON, conversion may fail
- Recommend verifying JSON validity before conversion
Data Integrity
- JSON Compression: Only removes whitespace characters, does not change data content
- JSON Compression and Escape: Escapes special characters, but data content remains unchanged
- Extract JSON Keys: Only extracts key names, does not include values, data content will be lost
Performance Considerations
- For large JSON files (exceeding several MB), formatting operations may take some time
- Deeply nested JSON may produce long lists when extracting keys
Special Character Processing
- Compression and Escape feature will escape all special characters, including quotes, backslashes, line breaks, etc.
- Escaped JSON can be directly used as a string without manually adding escape characters
Related Features
- Special Paste Formats: Learn more about format conversion features
- Paste as Plain Text: Remove all formatting
- Continuous Paste Mode: Batch process multiple JSON contents