Skip to main content

Float Generator

Generates random floating-point (decimal) numbers within a specified range.

Basic Usage

{
"price": {"gen": "float"}
}

Without options, generates any float value.

Options

OptionTypeDefaultDescription
minnumberInteger.MIN_VALUEMinimum value (inclusive)
maxnumberInteger.MAX_VALUEMaximum value (inclusive)
decimalsinteger2Number of decimal places (max: 10)

Examples

Price

{
"price": {"gen": "float", "min": 9.99, "max": 999.99, "decimals": 2}
}

Output: Random float between 9.99 and 999.99 with 2 decimal places (e.g., 49.99)

Percentage

{
"percentage": {"gen": "float", "min": 0, "max": 100, "decimals": 1}
}

Output: Random float between 0.0 and 100.0 with 1 decimal place (e.g., 73.5)

Temperature

{
"temperature": {"gen": "float", "min": -20.0, "max": 40.0, "decimals": 1}
}

Rating

{
"rating": {"gen": "float", "min": 1.0, "max": 5.0, "decimals": 1}
}

Output: Random rating like 4.2, 3.7, etc.

High Precision

{
"coordinate": {"gen": "float", "min": -180, "max": 180, "decimals": 6}
}

Output: Precise coordinates like 123.456789

Common Patterns

Product Pricing

{
"products": {
"count": 100,
"item": {
"id": {"gen": "uuid"},
"name": {"gen": "lorem.word"},
"price": {"gen": "float", "min": 9.99, "max": 999.99, "decimals": 2},
"discount": {"gen": "float", "min": 0, "max": 50, "decimals": 0}
}
}
}

Financial Data

{
"transactions": {
"count": 500,
"item": {
"id": {"gen": "uuid"},
"amount": {"gen": "float", "min": 10.00, "max": 10000.00, "decimals": 2},
"fee": {"gen": "float", "min": 0.50, "max": 50.00, "decimals": 2},
"taxRate": {"gen": "float", "min": 0.05, "max": 0.15, "decimals": 3}
}
}
}

Measurements

{
"measurements": {
"count": 1000,
"item": {
"id": {"gen": "uuid"},
"weight": {"gen": "float", "min": 0.1, "max": 100.0, "decimals": 2},
"height": {"gen": "float", "min": 0.5, "max": 2.5, "decimals": 2},
"temperature": {"gen": "float", "min": 15.0, "max": 30.0, "decimals": 1}
}
}
}

Ratings and Scores

{
"reviews": {
"count": 200,
"item": {
"id": {"gen": "uuid"},
"rating": {"gen": "float", "min": 1.0, "max": 5.0, "decimals": 1},
"score": {"gen": "float", "min": 0, "max": 100, "decimals": 1}
}
}
}

Geographic Coordinates

{
"locations": {
"count": 50,
"item": {
"id": {"gen": "uuid"},
"latitude": {"gen": "float", "min": -90, "max": 90, "decimals": 6},
"longitude": {"gen": "float", "min": -180, "max": 180, "decimals": 6}
}
}
}

Best Practices

  1. Always Specify Range: Use min and max for predictable data
  2. Appropriate Decimals: Use 2 decimals for currency, 1 for percentages, 6 for coordinates
  3. Realistic Ranges: Choose ranges that match real-world scenarios
  4. Currency Format: Use 2 decimals for monetary values
  5. Max Decimals: Maximum of 10 decimal places supported

Comparison with Number

GeneratorOutput TypeUse Case
FloatDecimal numbersPrices, measurements, ratings
NumberIntegersCounts, IDs, quantities

Next Steps