We propose and demonstrate a reconfigurable tunable encoder for two-dimensional time–wavelength optical code division multiple access (OCDMA). This encoder is capable of creating 2D codes with variable code weight, enabling differentiated service provisioning. The demonstrated novel scheme uses ultra-fast optical delay lines and all-optical sampling while operating at 115 Gchip/s. Our proposed architecture provides an all-optical method of varying the code weight on a bit-per-bit basis, while maintaining the core architecture of a tunable OCDMA encoder.