Random number of 6 digits with 3 diffrent digits

Hello community,

For a door system i need to generate a random code of 6 digits, with a minimum of 3 diffrent digits.

(And 123456 or 654321 is not allowed too.)

How can i do this?

Thanks a lot for every answer.


Hey @gruppenferienhaus.de

It can be tricky, but you can use the random and floor functions, and utilize the replace function to remove ‘123456’ and ‘654321’.


thanks for the reply. These numbers are very rare (123456 oder 654321).

What is more important to solve is the problem that there must be at least 3 different numbers. I now have 4 random numbers generated: Variable_1, Variable_2, Variable_3 and Variable 4. If all numbers should be 4444 at random, variable 5 must not be 4 and variable 6 must not be 4 or variable 5.

Another option: I have the first 3 digits generated in the range 0-4 and the second in the range 5-9. But even then the first 3 digits could be e.g. 333 and the second block 888, then it doesn’t work again… Difficult for me…

or the first digits have the range 0-7 and the last two digits always have 8 and 9 that would be a solution that is relatively easy to implement.

You are probably overthinking this.

I think there’s a much simpler solution. You generate three unique numbers separately to three filler numbers, then you combine and shuffle the order about.

samliewrequest private consultation


Thanks a lot, that would be the solution, but how can i combine and shuffle the number?

To Shuffle i need an array and that dont´t work… sorry i´m new with make.com

grettings from germany


To create an array of characters from a string, you can use the built-in function split.

For more information, see https://www.make.com/en/help/functions/string-functions#split--text--separator-

samliewrequest private consultation


thanks a lot, now it works. I spend a lot of time for this. :grinning: :+1:



Welcome to the Make community!

Yes, that is possible. You’ll need a minimum of one module:




Give it a go and let us know if you have any issues!

Module Export

You can copy and paste this module export into your scenario. This will paste the modules shown in my screenshots above.

  1. Copy the JSON code below by clicking the copy button when you mouseover the top-right of the code block

  2. Enter your scenario editor. Press ESC to close any dialogs. Press CTRLV (paste keyboard shortcut for Windows) to paste directly in the canvas.

  3. Click on each imported module and save it for validation. You may be prompted to remap some variables and connections.


  "subflows": [
      "flow": [
          "id": 40,
          "module": "util:SetVariable2",
          "version": 1,
          "mapper": {
            "name": "random_code",
            "scope": "roundtrip",
            "value": "{{join(shuffle(merge(slice(shuffle(split(formatNumber(1234567890; 0; emptystring; emptystring); emptystring)); 0; 3); slice(split(replace(uuid; \"/\\D+/g\"; emptystring); emptystring); 0; 3))); emptystring)}}"
          "metadata": {
            "designer": {
              "x": 0,
              "y": 0,
              "name": "Generate Code"
  "metadata": {
    "version": 1

samliewrequest private consultation