User Agent Random icon

User Agent Random

Generate random User-Agent headers for HTTP requests

Overview

This node generates random User-Agent headers for HTTP requests. It is useful when you want to simulate different browsers or devices in your web scraping, testing, or API calling workflows to avoid detection or mimic real user traffic. The node supports selecting User-Agents from a predefined library, dynamically generating new ones with random components, or using a custom list provided by the user.

Practical examples:

  • Web scraping: Rotate User-Agent strings to reduce the chance of being blocked.
  • API testing: Simulate requests from various browsers or devices.
  • Automation: Add realistic User-Agent headers to HTTP requests for better compatibility.

Properties

Name Meaning
Mode Source of User-Agent:
- Random (Predefined Library)
- Dynamic Generation
- Custom
User-Agent Type Browser type to use (only for "Random" mode):
- Desktop Browser
- Mobile Browser
- All Types
Custom User-Agent List List of User-Agent strings (one per line) to randomly select from (only for "Custom" mode)
Output Method How to output the generated User-Agent:
- User-Agent Only (returns only the string)
- Add as Item Property (adds User-Agent to each input item)
- Create Full HTTP Headers (creates full HTTP headers object including User-Agent)
Property Name Property name to store the User-Agent when using "Add as Item Property" output method
Headers Property Name Property name to store HTTP headers when using "Create Full HTTP Headers" output method
Merge Existing Headers Whether to merge the User-Agent into existing headers if the headers property already exists (boolean, only for "Create Full HTTP Headers")

Output

The output depends on the selected output method:

  • User-Agent Only: Outputs items where the JSON contains a single field userAgent with the generated User-Agent string.
  • Add as Item Property: Outputs items with the original JSON plus an additional property (name configurable) containing the User-Agent string.
  • Create Full HTTP Headers: Outputs items with the original JSON plus a property (name configurable) containing an HTTP headers object that includes the "user-agent" header set to the generated User-Agent string. If merging is enabled and the headers property exists, the User-Agent is merged into it.

No binary data is produced by this node.

Dependencies

  • No external services or API keys are required.
  • The node uses an internal service (generateUserAgent) to produce User-Agent strings either from a predefined library or via dynamic generation.
  • No special environment variables or n8n credentials are needed.

Troubleshooting

  • Empty Custom User-Agent List: If the mode is set to "Custom" but no User-Agent strings are provided, the node will throw an error indicating the list is empty. To fix, provide at least one User-Agent string in the multiline input.
  • Invalid Property Names: When adding properties or headers, ensure the property names do not conflict with existing important fields in your data to avoid overwriting.
  • Merging Headers: If merging is enabled but the existing headers property is not an object, the node will overwrite it with a new headers object containing only the User-Agent header.

Links and References

Discussion